Error while compiling C++ API and Sample Application

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

pratts
Posts: 34
Joined: 23 Aug 2016, 17:46

Error while compiling C++ API and Sample Application

Postby pratts » 27 Jun 2017, 18:48

Hello,
I could successfully compile the C++ api.
I tried to create a basic application (only contains one hello world program) and defined the dependencies. I am getting a compilation error :
00:25:43 **** Incremental Build of configuration Debug for project Sample ****
make all
Building target: Sample
Invoking: Cross G++ Linker
g++ -L/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug -L/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Core/BoostAsio/Unix/stage/lib -o "Sample" ./src/Sample.o -lboost_system -lpthread -lSmartFoxClientApi
/usr/bin/ld: warning: libboost_thread.so.1.59.0, needed by /opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so, not found (try using -rpath or -rpath-link)
makefile:45: recipe for target 'Sample' failed
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::this_thread::hiden::sleep_until(timespec const&)'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::thread::start_thread_noexcept()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::thread::detach()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::thread::native_handle()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::thread::interrupt()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::this_thread::interruption_point()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::detail::make_ready_at_thread_exit(boost::shared_ptr<boost::detail::shared_state_base>)'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `vtable for boost::detail::thread_data_base'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::detail::get_current_thread_data()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `typeinfo for boost::detail::thread_data_base'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::thread::join_noexcept()'
/opt/SmartFoxServer_2X/SFS2X_API_Cpp_v1.7.3/Debug/libSmartFoxClientApi.so: undefined reference to `boost::future_category()'
collect2: error: ld returned 1 exit status
make: *** [Sample] Error 1

00:25:43 Build Finished (took 285ms)

OS : Debian 8
api version : 1.7.3
eclipse Version: Neon.3 Release (4.6.3)
Any help would be appreciated.

Thank you.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error while compiling C++ API and Sample Application

Postby Lapo » 28 Jun 2017, 08:41

Hi,
I think you're missing a reference to the boost thread lib, as per the error message:
/usr/bin/ld: warning: libboost_thread.so.1.59.0, needed by


I am not very familiar with C++ development in Ubuntu but it looks like you need to add -lboost_thread to the compiler command

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error while compiling C++ API and Sample Application

Postby Lapo » 26 Mar 2018, 07:42

Are you sure that your linker sees the folder where the library is located?
That usually fixes the issue.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 46 guests