Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Linking .so library

(1/2) > >>

ValeV:
I'm having troubles linking .so library to the project. I got the library from https://github.com/tensaix2j/binacpp.

To the project I added:
Project -> Build Options -> select Release on the left side -> Search Directories -> Compiler -> added "lib\lib\libbinacpp\include"
Project -> Build Options -> select Release on the left side -> Linker Settings -> Link libraries added "lib\lib\libbinacpp\lib\libbinacpp.so"

Then in my code I call
--- Code: ---BinaCPP::init(m_apiKey, m_secretKey);
--- End code ---
, but get error "undefined reference to BinaCPP::init".

Miguel Gimenez:
Did you compile the library or just downloaded the binary?

Post a full rebuild log

ValeV:
I didn't compile, isn't library basically a precompiled code ready to use?


--- Code: ----------------- Clean: Release in AssuringBot (compiler: gnu_gcc_compiler_w64_wxwidgets)---------------

Cleaned "AssuringBot - Release"

-------------- Build: Release in AssuringBot (compiler: gnu_gcc_compiler_w64_wxwidgets)---------------

g++.exe -Wall -std=gnu++11 -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -O2 -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_lib\mswu -I"C:\Program Files\OpenSSL-Win64\include" -Ibinance_api\lib\libcurl-7.56.0\include -Ibinance_api\lib\jsoncpp-1.8.3\include -Ibinance_api\lib\libwebsockets-2.4.0\include -Ibinance_api\lib\libbinacpp\include -c C:\Users\M0097932\Desktop\AssuringBot\AssuringBotApp.cpp -o obj\Release\AssuringBotApp.o
g++.exe -Wall -std=gnu++11 -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -O2 -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_lib\mswu -I"C:\Program Files\OpenSSL-Win64\include" -Ibinance_api\lib\libcurl-7.56.0\include -Ibinance_api\lib\jsoncpp-1.8.3\include -Ibinance_api\lib\libwebsockets-2.4.0\include -Ibinance_api\lib\libbinacpp\include -c C:\Users\M0097932\Desktop\AssuringBot\AssuringBotMain.cpp -o obj\Release\AssuringBotMain.o
windres.exe -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_lib\mswu  -J rc -O coff -i C:\Users\M0097932\Desktop\ASSURI~1\resource.rc -o obj\Release\resource.res
g++.exe -LC:\wxWidgets-3.1.2\lib\gcc_lib -o bin\Release\AssuringBot.exe obj\Release\AssuringBotApp.o obj\Release\AssuringBotMain.o  obj\Release\resource.res -s  -mthreads  -lwxmsw31u_core -lwxbase31u -lwxpng -lwxjpeg -lwxtiff -lwxzlib "C:\Program Files\OpenSSL-Win64\lib\openssl.lib" binance_api\lib\libbinacpp\lib\libbinacpp.so binance_api\lib\libcurl-7.56.0\lib\libcurl.a binance_api\lib\libwebsockets-2.4.0\lib\libwebsockets.a -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -lshlwapi -lversion -loleacc -luxtheme -mwindows
In file included from binance_api\lib\libcurl-7.56.0\include/curl/system.h:389,
                 from binance_api\lib\libcurl-7.56.0\include/curl/curl.h:38,
                 from binance_api\lib\libbinacpp\include/binacpp.h:22,
                 from C:\Users\M0097932\Desktop\AssuringBot\AssuringBotMain.cpp:15:
C:/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
 #warning Please include winsock2.h before windows.h
  ^~~~~~~
obj\Release\AssuringBotMain.o:AssuringBotMain.cpp:(.text+0x18d1): undefined reference to `BinaCPP::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 6 second(s))
2 error(s), 1 warning(s) (0 minute(s), 6 second(s))
 

--- End code ---

Miguel Gimenez:
The precompiled libraries are intended to be used with the same compiler that created them, you can not pick a random library and link with it. For added trouble, the .so is a Linux library.

You need to compile the library yourself using the same x86_64-8.1.0-posix-seh-rt_v6-rev0 compiler and the makefile in the src folder

AndrewCot:
.so libraries are for Linux, NOT Windows. On Windows the equivalent is a .DLL.  As you are trying to use the .so on Windows it will NOT work, unless it is a DLL that has a wrong extension.

You will need to rebuild the library from source code to get it to work on Windows, but you will need to create a new makefile or C::B project to do this as the existing makefile is for unix only. It may be easier for you to find another Binance library that is for MINGW or MSYS2 and use it (it will probably need to be built, but should include the relevant files)

Navigation

[0] Message Index

[#] Next page

Go to full version