Programming :: "Unresolved Reference" Error While Doing Dynamic Linking Of C++ (shared Object)
Apr 13, 2011
I am creating two shared libs that i intend to be dynamically linkable in C and C++, cross platform Linux/Windows/Mac. As a basic sketch, true for both libs, the lib code is in several .c/.cpp and .h files. For now, I'll talk about the part that I am actively working on, a lib named Discover, i.e. libdiscover.so.1.0. First, everything is in a namespace, RemKon_Discover.
The main Discover.cpp defines the methods for the Discover class (declared in Discover.h) and has extern "C' routines that can return pointers to my main c++ object. The call to GetLibraryMainPointer() creates a Discover class object, theMainObject (ok, I win a prize for dumb names) and returns the (non-mangled) pointer to the caller over in my test program. The Discover class itself is declared extern "c" and the tester program #includes "Discover.h".
In the test program, dlopen() correctly opens the lib and dlsym() gets the pointer to theMainObject. However, when I use that pointer in the tester program to access a method (aDiscoverObject->hello(), e.g.) I get compile time errors saying that Discover::hello() in an undefined reference. My makefile is attached.
I have created a simple test class - Mortgage, with the class declaration in the .h file and the class's methods defined in the .cpp file. (mortgage.h && mortgage.cpp, respectively) Straight up C++ 101 as far as I can tell. I instantiate the class in the main() function, which is defined in practice.cpp. Using Geany on Ubuntu, both the practice.o and mortgage.o files are created, but then I get a linker error: undefined reference to class::functionName
I get it for each function. If the mortgage.cpp file is foremost in the editor when I click "build", then I get the undefined reference to main() error, if practice.cpp is foremost (where the main() function is) then I get undefined reference to Mortgage::Mortgage(), and all the rest of the functions defined for that class. How do I get the linker to know where my object files are so it will link them in? Or is the problem somewhere else entirely?
I have written an OpenGL based program which uses i.a. libjpeg that I want to link statically so I can send it to someone who doesn't have all the libraries needed installed to allow for a dynamically linked executable to run. As such I tried with giving the [b]-static[b] parameter to gcc.
I've been using the PPA version of banshee, and I got this error - just wondering if anyone else has it too! I'm able to play a song, but when the song finishes and the next one starts I get this error: Banshee Encountered a Fatal Error Object reference not sent to an instance of an object Error details:
Code: An unhandled exception was thrown: Object reference not set to an instance of an object at Hyena.Gui.Theming.GtkTheme.GetCairoTextMidColor (Gtk.Widget) <0x00017> at Banshee.NotificationArea.NotificationAreaService.get_TextLightColor () <0x0002f> at Banshee.NotificationArea.NotificationAreaService.MarkupFormat (string,string) <0x00043> at Banshee.NotificationArea.NotificationAreaService.GetByFrom (string,string,string,string) <0x000d7>
I've got an error with compiling a program: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/lib/python2.5/config/libpython2.5.a: could not read symbols: Bad value collect2: ld a retourn 1 code dtat d'excution make: *** [bindings/_yafqt.so] Erreur 1.
I am trying to add some function to the c++ project (calling function) and the called function are in C. And i am getting error "undefined reference to "Hello(int,int)" " while linking. It is compiling correctly. It is linking to header file mention in the calling function. This header file has definition to the c - called function. Do you thinking having c files into C++ project will be a problem? Should I remove <stdio.h> in c files?
How can I pass by reference, a parameter, without assigning a new object? In my first example, var = "changed" creates a new local object. In the second, mylist.append will affect the reference target. How to i achieve the same effect with example 1?
Code: #!/bin/python var = "unchanged" def print_string( var ):
I have an application consisting of different processes and all these processes are linked to shared libraries. I start the application (spawn all the different processes) as say user1. Now with the application up, if I run a process p1, the process gets activated and works. However, if I start the same process p1 as a different user, say user2, which is completely different from user1 the process complains of
"error while loading shared libraries:...."
I set LD_RUN_PATH both in compile and runtime environment. LD_LIBRARY_PATH is set correctly in both places.
All the above works if I set the absolute path of the required shared libraries in /etc/ld.so.conf file and rebuild the /etc/ld.so.cache
Alright, just loaded a fresh copy of OpenSuSE 11.3 x64, went to update manager and let it update, came back and computer was shut down. After booting it back up, I cannot update any software, nor run any commands.
Here is my output:
Code: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory I've tried searching for this error, some people came back saying to run this:
But all that happens is this:
Nor ls work either so I'm stuck and thinking about a reinstall.
I don't understand how this system could be so messed up after a failed update.. Used to trust SuSE, not sure anymore after this incident..
just installed Ubuntu 10.04 and installed the flightgear package and the fgfs-base package. I ran fgfs from a terminal and got this error:
Code: $ fgfs fgfs: error while loading shared libraries: libOpenThreads.so.12: cannot open shared object file: No such file or directory $ So then I did: Code: sudo apt-get install libopenthreads12 and it gave me these errors:
I'm trying to run Kega Fusion on my laptop, which can now FINALLY run Linux (ATI drivers finally work on it), and I can't get the emulator to work..
Code: brandon@brandon-laptop:~/Desktop/Fusion$ ./Fusion ./Fusion: error while loading shared libraries: libGLU.so.1: cannot open shared object file: No such file or directory brandon@brandon-laptop:~/Desktop/Fusion$ uname -a Linux brandon-laptop 2.6.32-24-generic #38-Ubuntu SMP Mon Jul 5 09:20:59 UTC 2010 x86_64 GNU/Linux brandon@brandon-laptop:~/Desktop/Fusion$ Help? I have the ATI proprietary drivers installed. I tried without them and it still wouldn't work. (And OpenGL is seemingly working as Compiz Fusion is running. I also tried with Compiz disabled but the same error pops up).
I'm running lucid 32-bit. I get this error when I try to run the installer for Unreal Tournament GOTY:
Code: Verifying archive integrity... All good. Uncompressing Unreal Tournament 436-multilanguage.goty Installer. /home/computer/.setup1548: error while loading shared libraries: libgtk-1.2.so.0: cannot open shared object file: No such file or directory computer@computer-desktop:~/UnrealInstall$ I tried installing libgtk1.2 (as told by some people in other threads), but couldn't do that:
Code: E: Couldn't find package libgtk1.2 However, I checked that I do have libgtk2.0 So what should I do?
After finally getting my wireless/graphics drivers working yesterday (thanks to this forum ) I startx to realize that not a single KDE/Qt application will launch, along with Firefox, or Chrome/Chromium. (I did a full install from the DVD, not deselecting anything, and when I upgraded to -current, I also did the same.)
ark: error while loading shared libraries: liblzma.so.0: cannot open shared object file: No such file or directory
but I managed to fix that one by commenting out 'aaa_elflibs' in /etc/slackpkg/blacklist (on a recommendation from #slackware), and running slackpkg upgrade-all again, but that's the only one (afaik) that was fixed. Ark still doesn't work, but it doesn't show that error anymore. When I run it, a box pops up that says "Unable to find Ark's KPart component, please check your installation."
Kate still says:
kate: error while loading shared libraries: libkemoticons.so.4: cannot open shared object file: No such file or directory
Now, konsole, firefox, and Chromium's errors are a little different.
konsole: symbol lookup error: /usr/lib/libphonon.so.4: undefined symbol: _ZN9QMetaType15registerTypedefEPKci
Firefox and Chrome basically say the same thing
/usr/lib/firefox-3.6.13/firefox-bin: symbol lookup error: /usr/lib/mozilla/plugins/skypebuttons.so: undefined symbol: _ZN9QListData11detach_growEPii
again, I am completely baffled here, as I had kate, konsole and ark running before I upgraded to -current.
I upgrade the system from 11.1 to 11.2 seems everything work fine, no error no warning, after a reboot the consol show : mount error while loading shared libraries: libvolume_id.so.1: Cannot open shared object file: No such file or directory. when I try to repair the system the repair tool cannot find the root partion,
I installed the latest Gimp beta and it worked fine but then I couldn't open it. I removed it and I reinstalled but it didn't work, so I installed the latest stable version (no beta) and it still does not work, when I open it form Terminal, this is the response:gimp: error while loading shared libraries: libbabl-0.0.so.0: cannot open shared object file: No such file or directory
Any good tutorial on sharing dynamically allocated objects across shared libraries in the same process and between shared libaries and main(). In particular, I need to know what creation and destruction sequences are valid when libraries are being loaded and unloaded. For example, is it valid to allocate an object from inside a shared library procedure, and then delete that pointer from a different module, especially in the case where the allocating module has already been unloaded.
I imagine there might be all kinds of problems with this. Although my preliminary tests seem to work most of the time, I get crashes from time to time, but I'm not sure if they're caused by memory management or by threading issues. I've been restructuring my code to use a global context object to manage object creation and destruction from main(), but I'd like to find a clear exposition of the specific issues I'm dealing with before I go too much further.
I have created an application that has a executable program that loads in a shared object
the shared object loads in another shared object
both of these shared object I have created
For debugging I have been printf'in data to determine what is going on
I now have some odd memory issue, and need a bit more control over debugging...
I have one workspace set up and under my exectuable(will call maintest from now on) I have two items in my link libraries under project build options being soA and soB (so A is the shared object that maintest uses, soB is the SO that soA uses) I also have linker options pthread and ldl
At the beginning of my maintest I do my dlsym and load in each function that I will be using
I always run my program using maintest, because when I have one of the SO as the startup project(turns bold) and try to run it gives me "You must select a host application to run a library"
I tried to set up this host library, i Go to Menu->Project->SetProgramArguments and change the Host Application to the debug version of my maintest
I then hit OK and try to run again but I get the same error: "You must select a host application to run a library"
If I get this part working - which I need help doing, is tehre other steps that need to be taken to debug the so's? or will this make it so when i hit f8 it will run.
I wanted to know how can I change the default place of shared object files of a program in a system. let me explain it better for you : I have an embedded computer with Linux OS that its file system is read only and I can not add any file to /usr /lib and ..... and I can just mount a SD memory card to it and copy all of my programs to it and run them from there as you understand I have two choices to choose, first make one big binary file for each program that I am doing it now and it is not a suitable solution and the second is finding the way to change default place of shared object file of my program.
I am trying to create a package for Moblin using the Moblin Package creator application in Ubuntu. The RPM package gets created successfully, but when I execute that package in Moblin OS in the terminal I get the following error message: Error while loading shared libraries: libgda-4.0.so.4: cannot open shared object file: No such file or directory.
I understand that the above libraries are missing on my system and I need to add them. My question here is do I have to add them manually after the installation of the package or can the package itself include these libraries and copy them to proper locations when the package is installed. In case the libraries can be included in the package I want to know how that can be done.
Our application uses a dynamically loaded shared object library (codec library) to compress and decompress audio streams.
There happens to be several static and global variables in this shared object library. Hence it is not possible to process two interleaved unrelated media streams using this shared object codec library because each stream corrupts/changes the contents of these static/global variables.
Is there a way through which a context save (save contents of data segment of shared object) and a context load (load previously saved contents of data segment of shared object)operation can be performed on the shared object library. This way the context for each media stream can be saved and loaded before and after processing the "other" media stream respectively.
I'm trying to build a shared library, and am receiving several undefined reference linking errors. Specifically, ffmpeg linked with libx264. I'm aware that this is not an appropriate forum for questions specific to ffmpeg or libx264. In order for one library / application (ffmpeg) to reference another library (libx264), the linker has to know where the referenced library (libx264.so) is located in the file system.
I'm pretty sure the linker knows where libx264.so is, because I receive a different error message when I run ffmpeg's configure script if the linker can't find libx264.so. In general, should running the install target of a make file be preferred over specifying the appropriate paths in the CFLAGS and LDFLAGS environment variables? I've tried both, and it doesn't seem to make a difference in regard to my error which method I choose.
How exactly is a library referenced? My error messages are /root/ffmpeg/libavcodec/libavcodec.so: undefined reference to `d26' /root/ffmpeg/libavcodec/libavcodec.so: undefined reference to `d22' /root/ffmpeg/libavcodec/libavcodec.so: undefined reference to `d2' /root/ffmpeg/libavcodec/libavcodec.so: undefined reference to `d20' /root/ffmpeg/libavcodec/libavcodec.so: undefined reference to `d24' /root/ffmpeg/libavcodec/libavcodec.so: undefined reference to `d0' /root/ffmpeg/libavcodec/libavcodec.so: undefined reference to `q1'
If I can find out what library 'd26', 'd22', etc. are declared in, I should be able to resolve the undefined references. What exactly are 'd26', 'd22', etc.? Are these functions, classes, or something else? How can I find out what functions / classes are defined in a particular library?
I am currently using Ubuntu 9.10. I am writing a small code in C which test the connectivity with MYSQL. I am getting this error. "libmysqlclient.so.14: cannot open shared object file: No such file or directory" What I understand is that you need MYSQL development package in order to access MYSQL database in C. I installed MYSQL using this command. apt-get install mysql-server mysql-client