Undefined symbol reference, although the library is linked

When linking the project I'm working on, the linker gives the following errors:

/usr/bin/ld: ../Includes and Libs/lib/libsfml21rca.a(SoundFile.o): undefined reference to symbol ' sf_read_short@ @libsndfile.so.1.0' /usr/bin/ld: note: ' sf_read_short@ @libsndfile.so.1.0' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libsndfile.so so try adding it to the linker command line /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libsndfile.so: could not read symbols: Invalid operation 

The point is that libsndfile.so is already linked before libsfml21rca.a, so I have no idea where the problem is.

I am using Code :: Blocks 10.05

Thanks for the help in advance.

EDIT:

Here's a link:

g ++ -L "Turns on and Libs / lib" -L "Turns on and Libs / lib / raknet3_731" -L "Turns on and Libs / lib / d3d_new / x86" -L "Turns on and Libs / lib / ogg" -L "Turns on and Libs / lib / sdl "-LBullet / lib -o (filename) ... (many object files) -lGLEW -lglfw -lGL -lGLU -lpthread -lopenal -ljpeg -lfreetype -lsndfile -lXrandr - lsfml-system -lsfml- window -lsfml-audio ../ Bullet / lib / LinearMath.lib ../ Bullet / lib / BulletCollision.lib ../ Bullet / lib / BulletDynamics.lib "../Includes and Libs / lib / raknet3_731 / RakNetLibStaticDebug.lib "" ../Includes and Libs / lib / libsfml21rca.a ".. /../../../../../home/msabol/Desktop/SFML/sfml2st/sfmlVideo/sfmlVideo/bin/Release /libsfmlVideo.a../../../../../../home/msabol/Desktop/SFML/sfmlVideo/bin/Release/libsfmlVideo.a

+6
source share
1 answer

The linker performs only one pass through the library files. Therefore, if there is something in library A that needs something in library B, you need to have g++ objects... -llibA -llibB , if you use g++ objects... -llibB -llibA , this will lead to a failure in the way you show.

So, in your case, put -lsndfile after "../Includes and Libs/lib/libsfml21rca.a" .

(And whose idea was to put spaces in the Includes and Libs directory - not the best idea I've seen ...)

+5
source

Source: https://habr.com/ru/post/949805/


All Articles