Loading ...
Sorry, an error occurred while loading the content.

Linking In User-Created Libraries

Expand Messages
  • Jason
    I have a folder of library files to be made for a robot platform that I want Tekkotsu to include in my project. There is already a Makefile ready to be used
    Message 1 of 8 , Mar 7, 2010
    • 0 Attachment
      I have a folder of library files to be made for a robot platform that I want Tekkotsu to include in my project. There is already a Makefile ready to be used in this folder. I added a variable to the Environment.conf file like this:

      MY_LIBS ?= /usr/myfolder

      and I added the path to the project Makefile like this:

      USERLIBS:=$(TK_FW_LIBS) \
      $(MY_LIBS)

      I was wondering if I just added it in the wrong spot, because the build can't seem to find the folder. Also, once the Makefile finds this folder, will Tekkotsu simply link all of these object files for me, or is there another file that I need to edit so that it looks for them?

      Jason Tennyson
    • Ethan Tira-Thompson
      ... There s two ways to approach this. One is to have MY_LIBS directly list the individual libraries (or something like $(wildcard /usr/myfolder/*.so) to
      Message 2 of 8 , Mar 7, 2010
      • 0 Attachment
        > I was wondering if I just added it in the wrong spot, because the build can't seem to find the folder. Also, once the Makefile finds this folder, will Tekkotsu simply link all of these object files for me, or is there another file that I need to edit so that it looks for them?


        There's two ways to approach this. One is to have MY_LIBS directly list the individual libraries (or something like $(wildcard /usr/myfolder/*.so) to automatically list them all). In this usage, make will test the libraries' timestamps and relink as needed.

        The other method is to add -L/usr/myfolder, and then list your libraries with '-l' (-lfoo -lbar ...) to the LDFLAGS variable. This will tell the linker about your libraries, but make won't check their timestamps.

        -Ethan
      • Jason
        Thanks, it appears to be linking them in now.
        Message 3 of 8 , Mar 8, 2010
        • 0 Attachment
          Thanks, it appears to be linking them in now.

          --- In tekkotsu_dev@yahoogroups.com, Ethan Tira-Thompson <ejt@...> wrote:
          >
          > > I was wondering if I just added it in the wrong spot, because the build can't seem to find the folder. Also, once the Makefile finds this folder, will Tekkotsu simply link all of these object files for me, or is there another file that I need to edit so that it looks for them?
          >
          >
          > There's two ways to approach this. One is to have MY_LIBS directly list the individual libraries (or something like $(wildcard /usr/myfolder/*.so) to automatically list them all). In this usage, make will test the libraries' timestamps and relink as needed.
          >
          > The other method is to add -L/usr/myfolder, and then list your libraries with '-l' (-lfoo -lbar ...) to the LDFLAGS variable. This will tell the linker about your libraries, but make won't check their timestamps.
          >
          > -Ethan
          >
        • Jason
          So although the linker is spitting out my additional file path, the function implementations are still not being found. Just as a sanity check, I am going to
          Message 4 of 8 , Mar 9, 2010
          • 0 Attachment
            So although the linker is spitting out my additional file path, the function implementations are still not being found. Just as a sanity check, I am going to post where I put the line for confirmation that I am doing it correctly. I have already built the libraries myself, and checked them with nm to make sure they weren't stripped or anything strange. I simply just want to link the pre-compiled libraries in. Under MAKEFILE VARIABLES, in the else statement with LDFLAGS, I put -L/usr/myfiles -lmylib like so:

            ifeq ($(TEKKOTSU_TARGET_PLATFORM),PLATFORM_APERIOS)
            PLATFORM_FLAGS:= \
            -isystem $(OPENRSDK_ROOT)/OPEN_R/include/MCOOP \
            -isystem $(OPENRSDK_ROOT)/OPEN_R/include/R4000 \
            -isystem $(OPENRSDK_ROOT)/OPEN_R/include \
            -isystem $(TEKKOTSU_ROOT)/aperios/include \
            $(if $(TEKKOTSU_DEBUG),-DOPENR_DEBUG,) -DLOADFILE_NO_MMAP \
            $(shell $(TEKKOTSU_ROOT)/aperios/bin/xml2-config --cflags)
            LDFLAGS:=$(LDFLAGS) -lObjectComm -lOPENR -lInternet -lantMCOOP -lERA201D1 \
            $(shell $(TEKKOTSU_ROOT)/aperios/bin/xml2-config --libs) -ljpeg -lpng -lregex
            else
            PLATFORM_FLAGS:=$(shell xml2-config --cflags) -isystem /usr/include/libpng12 \
            #enable -fPIC if we are building shared libraries on x86_64/amd64
            ifneq ($(filter __amd64__ __x86_64__,$(shell g++ $(CXXFLAGS) -dM -E - < /dev/null)),)
            ifneq ($(suffix $(LIBTEKKOTSU)),.a)
            PLATFORM_FLAGS:=$(PLATFORM_FLAGS) -fPIC
            endif
            endif
            LDFLAGS:=$(LDFLAGS) -rdynamic $(shell xml2-config --libs) $(if $(shell locate librt.a 2> /dev/null),-lrt) \
            -lreadline -lncurses -ljpeg -lpng12 -lpthread -lasound \
            -L/usr/myfiles -lmylib \
            $(if $(FLYCAP_ROOT),-lflycapture) \
            $(if $(findstring Darwin,$(shell uname)),-bind_at_load -framework Quicktime -framework Carbon)
            endif


            --- In tekkotsu_dev@yahoogroups.com, Ethan Tira-Thompson <ejt@...> wrote:
            >
            > > I was wondering if I just added it in the wrong spot, because the build can't seem to find the folder. Also, once the Makefile finds this folder, will Tekkotsu simply link all of these object files for me, or is there another file that I need to edit so that it looks for them?
            >
            >
            > There's two ways to approach this. One is to have MY_LIBS directly list the individual libraries (or something like $(wildcard /usr/myfolder/*.so) to automatically list them all). In this usage, make will test the libraries' timestamps and relink as needed.
            >
            > The other method is to add -L/usr/myfolder, and then list your libraries with '-l' (-lfoo -lbar ...) to the LDFLAGS variable. This will tell the linker about your libraries, but make won't check their timestamps.
            >
            > -Ethan
            >
          • Ethan Tira-Thompson
            ... Yeah, that looks correct. Wild guess... is this library compiled from plain-C code? You might need to wrap the headers with the ifdef __cplusplus extern
            Message 5 of 8 , Mar 9, 2010
            • 0 Attachment
              > So although the linker is spitting out my additional file path, the function implementations are still not being found. Just as a sanity check, I am going to post where I put the line for confirmation that I am doing it correctly.
              Yeah, that looks correct.
              Wild guess... is this library compiled from plain-C code? You might need to wrap the headers with the ifdef __cplusplus extern "C" stuff so it does the symbol mangling properly.
              Otherwise it might help to see the end-game output from make...
              -Ethan
            • Jason
              I will be away from my workstation for the end of this spring break week, but I wanted to let you know that I read your comment instead of leaving no response
              Message 6 of 8 , Mar 9, 2010
              • 0 Attachment
                I will be away from my workstation for the end of this spring break week, but I wanted to let you know that I read your comment instead of leaving no response for 5 days. I think you may be on to something with the plain c code comment. I am compiling a library that is made by a company I work with cooperatively, and I believe that the source code is in plain c.

                As far as the output from make, it just spits out all of the library names from the line where I include my library, including the line I added (while creating the executable), and then spits out "undefined reference" for every function I am trying to reference from those libraries in my robot driver.

                --- In tekkotsu_dev@yahoogroups.com, Ethan Tira-Thompson <ejt@...> wrote:
                >
                > > So although the linker is spitting out my additional file path, the function implementations are still not being found. Just as a sanity check, I am going to post where I put the line for confirmation that I am doing it correctly.
                > Yeah, that looks correct.
                > Wild guess... is this library compiled from plain-C code? You might need to wrap the headers with the ifdef __cplusplus extern "C" stuff so it does the symbol mangling properly.
                > Otherwise it might help to see the end-game output from make...
                > -Ethan
                >
              • Jason
                I got the executable linked together but it crashes immediately when running. I know that this is a pretty difficult thing for you to offer advice on, but I
                Message 7 of 8 , Mar 16, 2010
                • 0 Attachment
                  I got the executable linked together but it crashes immediately when running. I know that this is a pretty difficult thing for you to offer advice on, but I thought maybe you knew why it would throw the error that it throws. If it helps I can e-mail you my driver:

                  Tekkotsu Robotics Framework 5.02-CVS, libtekkotsu compiled on Mar 16 2010 at 16:23:37
                  Found a Mary text-to-speech server.
                  SZ_KHR2Driver "SZ_KHR2": could not find CommPort ""
                  Driver 'SZ_KHR2' does not have any data sources
                  SOUND: Error opening PCM device plughw:0,0
                  Wireless::listen: bind: Address already in use
                  Wireless::listen: bind: Address already in use
                  Servo:0=0
                  Servo:1=0
                  Servo:2=0
                  Servo:3=0
                  Servo:4=0
                  Servo:5=0
                  Servo:6=0
                  Servo:7=0
                  Servo:8=0
                  Servo:9=0
                  Servo:10=0
                  Servo:11=0
                  Servo:12=0
                  Servo:13=0
                  Servo:14=0
                  Servo:15=0
                  Servo:16=0
                  *** ERROR Motion: Received SIGSEGV
                  Stack Trace:
                  0 sim::handle_signal(int) +0x1da*** PAUSED ***
                  Wireless::listen: bind: Address already in use
                  Wireless::listen: bind: Address already in use
                  Wireless::listen: bind: Address already in use
                  Wireless::listen: bind: Address already in use
                  (usr/local/Tekkotsu/local/tekkotsu/sim.cc:514)
                  1 __kernel_sigreturn +0 (0xb7f64400, offset 0xb7f64000 in unknown lib)
                  2 bsBotMoveToPosAllMotors +0x1aHAL:SZ_KHR2> (usr/SkewlZone/botsense/libBotSense/bsLibBot.c:1299)
                  3 SZ_KHR2Driver::motionCheck(float const (*) [17]) +0x15d (libtekkotsu.so) (usr/local/Tekkotsu/local/DeviceDrivers/SZ_KHR2Driver.cc:107)
                  4 Simulator::updateMotion(float const (*) [17]) +0x71 (usr/local/Tekkotsu/local/tekkotsu/Simulator.cc:441)
                  5 MotionExecThread::poll() +0x6db (usr/local/Tekkotsu/local/tekkotsu/MotionExecThread.cc:92)
                  6 PollThread::run() +0x29f (libtekkotsu.so) (usr/local/Tekkotsu/IPC/PollThread.cc:58)
                  7 Thread::launch(void*) +0x2bb (libtekkotsu.so) (usr/local/Tekkotsu/IPC/Thread.cc:302)
                  8 start_thread (libpthread.so.0)
                  9 clone +0x5e (libc.so.6)
                  *** ERROR Motion: Engaging fault shutdown...
                  *** ERROR Motion: Dereferencing message queue SemaphoreManager
                  ERROR: SemaphoreManager unable to lower semaphore (semop): Invalid argument
                  Semaphore set was deleted.
                  Goodbye
                • Jason
                  Nevermind, I found the problem.
                  Message 8 of 8 , Mar 17, 2010
                  • 0 Attachment
                    Nevermind, I found the problem.

                    --- In tekkotsu_dev@yahoogroups.com, "Jason" <jtennys@...> wrote:
                    >
                    > I got the executable linked together but it crashes immediately when running. I know that this is a pretty difficult thing for you to offer advice on, but I thought maybe you knew why it would throw the error that it throws. If it helps I can e-mail you my driver:
                    >
                    > Tekkotsu Robotics Framework 5.02-CVS, libtekkotsu compiled on Mar 16 2010 at 16:23:37
                    > Found a Mary text-to-speech server.
                    > SZ_KHR2Driver "SZ_KHR2": could not find CommPort ""
                    > Driver 'SZ_KHR2' does not have any data sources
                    > SOUND: Error opening PCM device plughw:0,0
                    > Wireless::listen: bind: Address already in use
                    > Wireless::listen: bind: Address already in use
                    > Servo:0=0
                    > Servo:1=0
                    > Servo:2=0
                    > Servo:3=0
                    > Servo:4=0
                    > Servo:5=0
                    > Servo:6=0
                    > Servo:7=0
                    > Servo:8=0
                    > Servo:9=0
                    > Servo:10=0
                    > Servo:11=0
                    > Servo:12=0
                    > Servo:13=0
                    > Servo:14=0
                    > Servo:15=0
                    > Servo:16=0
                    > *** ERROR Motion: Received SIGSEGV
                    > Stack Trace:
                    > 0 sim::handle_signal(int) +0x1da*** PAUSED ***
                    > Wireless::listen: bind: Address already in use
                    > Wireless::listen: bind: Address already in use
                    > Wireless::listen: bind: Address already in use
                    > Wireless::listen: bind: Address already in use
                    > (usr/local/Tekkotsu/local/tekkotsu/sim.cc:514)
                    > 1 __kernel_sigreturn +0 (0xb7f64400, offset 0xb7f64000 in unknown lib)
                    > 2 bsBotMoveToPosAllMotors +0x1aHAL:SZ_KHR2> (usr/SkewlZone/botsense/libBotSense/bsLibBot.c:1299)
                    > 3 SZ_KHR2Driver::motionCheck(float const (*) [17]) +0x15d (libtekkotsu.so) (usr/local/Tekkotsu/local/DeviceDrivers/SZ_KHR2Driver.cc:107)
                    > 4 Simulator::updateMotion(float const (*) [17]) +0x71 (usr/local/Tekkotsu/local/tekkotsu/Simulator.cc:441)
                    > 5 MotionExecThread::poll() +0x6db (usr/local/Tekkotsu/local/tekkotsu/MotionExecThread.cc:92)
                    > 6 PollThread::run() +0x29f (libtekkotsu.so) (usr/local/Tekkotsu/IPC/PollThread.cc:58)
                    > 7 Thread::launch(void*) +0x2bb (libtekkotsu.so) (usr/local/Tekkotsu/IPC/Thread.cc:302)
                    > 8 start_thread (libpthread.so.0)
                    > 9 clone +0x5e (libc.so.6)
                    > *** ERROR Motion: Engaging fault shutdown...
                    > *** ERROR Motion: Dereferencing message queue SemaphoreManager
                    > ERROR: SemaphoreManager unable to lower semaphore (semop): Invalid argument
                    > Semaphore set was deleted.
                    > Goodbye
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.