When linking a C ++ dynamic library, unsuccessful character binding

I am writing dylib in C ++, but when I try to associate it with my application, it gives me an error while executing:

dyld: lazy symbol binding failed: Symbol not found: __ZN8Vector2DC1Ev
  Referenced from: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/Singularity Test App
  Expected in: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/libSingularity.dylib

dyld: Symbol not found: __ZN8Vector2DC1Ev
  Referenced from: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/Singularity Test App
  Expected in: /Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug/libSingularity.dylib

I made sure that the symbol is not without, and

nm -g libSingularity.dylib  | grep "T" | grep __ZN8Vector

reports that the symbol is present in the library:

0000000000006df6 T __ZN8Vector2DC1Eff
0000000000006d98 T __ZN8Vector2DC1Ev
0000000000006dc2 T __ZN8Vector2DC2Eff
0000000000006d6e T __ZN8Vector2DC2Ev

I am connecting from within Xcode, so the link commands look weird. Here's the linker command for dylib:

Ld "/Users/noahz/Desktop/Singularity/Singularity Engine/build/Debug
    /libSingularity.dylib" normal x86_64
cd "/Users/noahz/Desktop/Singularity/Singularity Engine"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/g++-4.2 -arch x86_64 -dynamiclib -isysroot /Develope
    /SDKs/MacOSX10.6.sdk "-L/Users/noahz/Desktop/Singularity/Singularity Engine/build
    /Debug" "-F/Users/noahz/Desktop/Singularity/Singularity Engine/build/Debug"
    -filelist "/Users/noahz/Desktop/Singularity/Singularity Engine/build/Singularity 
    Engine.build/Debug/Singularity Engine.build/Objects-normal/x86_64
    /libSingularity.LinkFileList" -install_name libSingularity.dylib -mmacosx-version-
    min=10.6 -framework sfml-system-d -framework sfml-window-d -framework SFML 
    -framework OpenGL -framework OpenAL -framework sfml-graphics-d -single_module 
    -compatibility_version 1 -current_version 1 -o "/Users/noahz/Desktop/Singularity
    /Singularity Engine/build/Debug/libSingularity.dylib"

and here is the test application linker command:

cd "/Users/noahz/Desktop/Singularity/Singularity Test App"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/g++-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk 
    "-L/Users/noahz/Desktop/Singularity/Singularity Test App/build/Debug" "-F/Users
    /noahz/Desktop/Singularity/Singularity Test App/build/Debug" -filelist "/Users/noahz
    /Desktop/Singularity/Singularity Test App/build/Singularity Test App.build/Debug
    /Singularity Test App.build/Objects-normal/x86_64/Singularity Test 
    App.LinkFileList" -mmacosx-version-min=10.6 "/Users/noahz/Desktop/Singularity
    /Singularity Engine/build/Debug/libSingularity.dylib" -o "/Users/noahz/Desktop
    /Singularity/Singularity Test App/build/Debug/Singularity Test App"

Any ideas on why this is happening and / or how to fix it?

+3
source share
3 answers

I solved the problem by linking the library statically. This is not as elegant as dynamic binding, but at least it does not break repeatedly.

0

x86/64 , , , .

.

0

I do not see the line at the link stage

-lSingularity

Apparently, another way to load a dynamic library is by its ease of loading code.

gSystem->Load("libSingularity");

I am simply paraphrasing the blog article I found.

http://root.cern.ch/phpBB3//viewtopic.php?f=3&t=10380&start=0

0
source

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


All Articles