User forums > Using Code::Blocks

undefined reference to shared library from shared library

<< < (2/3) > >>

stahta01:
You still need to add the missing library to the list.
Did not figure out how to add the library to the list from the links I posted?

Tim S.

MyMindsAvatar:
Under Build Options -> Linker Settings -> Link Libraries, I have:

for RunSamplesWorkspace (library A): Images (library B, with the path to the .so file added to the Search Directories -> Linker list)
for MainApp: Images (library B, as above), and RunSamplesWorkspace (library A, as above)

Under Properties -> Build Targets -> Dependencies, I have:

for MainApp: relative paths to both libraries
for RunSamplesWorkspace (library A): relative path to library B

Have I genuinely missed something here?

Thanks again for your help.

Richard ~

stahta01:

--- Quote ---Build log for MainApp (MainApp):
g++ -L../RunSamplesWorkspace/bin/Debug -L/home/richard/programming/wxWidgets-2.9.4/mybuild/lib  -o bin/Debug/MainApp obj/Debug/src/App.o   -L/usr/local/lib -pthread   -lwx_gtk2u-2.9    -lRunSamplesWorkspace
../RunSamplesWorkspace/bin/Debug/libRunSamplesWorkspace.so: undefined reference to `RunSamples::GetDeleteBitmap()'
     (message repeated for all namespace functions included, but are all defined in the library B implementation files)

--- End quote ---

Do you see the missing "Images" library above?
I do NOT see it.

Edit: Once you get the "Images" library in the list; I am guessing it should be to the end of the command.
Edit2: Just re-read the first post; CB by design does next to nothing implicitly; it is NOT Visual Studio which does so much implicitly that it is not worth using to learn to program. Once you know to program, VS should be OK; but, bad idea to use it to learn.

Tim S.

MyMindsAvatar:
My apologies, that must have been from an earlier attempt, but as you can see below it doesn't seem to make a difference (link order doesn't impact this either, -lImages can come after -lRunSamplesWorkspaces with no change in result):

g++ -L../RunSamplesWorkspace/bin/Debug -L../Images/bin/Debug  -o bin/Debug/MainApp obj/Debug/src/App.o   -L/usr/local/lib -pthread   -lwx_gtk2u-2.9    -lImages -lRunSamplesWorkspace
../RunSamplesWorkspace/bin/Debug/libRunSamplesWorkspace.so: undefined reference to `RunSamples::GetDeleteBitmap()'
(etc)

Though, forgive me if I'm wrong here, I didn't think that should matter when it's only library A (RunSamplesWorkspace) that uses library B (Images). I figured that A would depend on B, so would also be listed in ldd A, but because it isn't listed I suspect a linker problem with building A (for completeness, below is the latest build log).

g++ -shared -L../Images/bin/Debug  obj/Debug/src/TableArrangement.o obj/Debug/src/StatusGridCellRenderer.o obj/Debug/src/ItemExecutable.o obj/Debug/src/ItemsPanel.o obj/Debug/src/RunlistPanel.o   -o bin/Debug/libRunSamplesWorkspace.so -L/usr/local/lib -pthread   -lwx_gtk2u-2.9    -lImages

Thanks again,

Richard ~

stahta01:
The order matters for most linkers!


--- Code: ---g++ -L../RunSamplesWorkspace/bin/Debug -L../Images/bin/Debug  -o bin/Debug/MainApp obj/Debug/src/App.o   -L/usr/local/lib -pthread   -lwx_gtk2u-2.9    -lImages -lRunSamplesWorkspace
../RunSamplesWorkspace/bin/Debug/libRunSamplesWorkspace.so: undefined reference to `RunSamples::GetDeleteBitmap()'
(etc)

--- End code ---

Try to always paste the library you are adding at the end or the beginning if it still has the linking error.
In this case, the end is needed for GCC/g++.
So, move "-lImages" after "-lRunSamplesWorkspace"

Edit2: In code::blocks this means move the library down the list so "Images" is at the bottom.
I suggest adding all new libraries at the bottom of the list till you find a better way.

Tim S.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version