Building library in Ubuntu (Eclipse)

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

ramSe7en
Posts: 5
Joined: 13 Feb 2014, 17:40

Building library in Ubuntu (Eclipse)

Postby ramSe7en » 17 Mar 2014, 02:52

Hi,

Thanks for the help in advance.

I have been trying to get the library build in my Ubuntu machine (Eclipse). I was developing in windows machine, since VS2012 is supported by SFS library & VS2012 doesn't have full support for C++11, I had to move to Eclipse.

I have been trying it for days now, did everything I could, still not able to compile with 0 errors. I just followed the steps given in this page : http://docs2x.smartfoxserver.com/Gettin ... nt-api-cpp

I tried with "Linux GCC" & "Cross GCC" both tool chains, now it's down to this errors :
    * ./Util/md5/md5.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
    * "Symbol 'shared_ptr' could not be resolved"

Any help is appreciated. Thanks.
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: Building library in Ubuntu (Eclipse)

Postby MBagnati » 18 Mar 2014, 00:59

Hi,
To investigate the issue, I have repeated, on my Ubuntu machine (rel. 12.10) with Eclipse Juno, all steps described in chapter Linux/Unix — Eclipse Cygwin of http://docs2x.smartfoxserver.com/GettingStarted/client-api-cpp that are required to build the library .
I have collected some screenshots that describe step-by-step all actions that I have done.
I hope these screenshots can be a guideline to discover the difference between your environment where you see the failure and my computer
where the library is successfully built.

Step 01
Download C++ API from SmartFoxServer website and uncompress them in file system

Step 02
Run Eclipse
Screenshots show details about my Eclipse version

Step 03
Build Boost library
By execution of commands bootstrap and b2 I get Boost libraries in folder Core\BoostAsio\Unix\stage\lib

Step 04
Create Eclipse project.
I choose the Cross GCC toolchain to create the SmartFoxClientApi library in folder /home/massimo/Projects/SFS2X_API_Cpp_v1.1.0

Step 05
Exclude BoostAsio, SmartFoxClientApi, ZLib from build

Step 06
Set the preprocessor symbols

Step 07
Set the compiler path for included files

Step 08
Set the linked libraries

Step 09
Rebuild the project
API library is successfully built (some warnings but no errors)

Please, can you compare this guideline with your steps to discover which are the differences?
Attachments
Step 09 - Build completed - Second Part.png
(259.02 KiB) Not downloaded yet
Step 09 - Build completed - First Part.png
(122.32 KiB) Not downloaded yet
Step 08 - Set Linker Libraries.png
(193.74 KiB) Not downloaded yet
Step 07 - Set Compiler Include Path.png
(192.52 KiB) Not downloaded yet
Step 06 - Set Preprocessor Symbols.png
(197.69 KiB) Not downloaded yet
Step 05 - Exclude from Build.png
(122.94 KiB) Not downloaded yet
Step 04 - Create Eclipse Project.png
(119.2 KiB) Not downloaded yet
Step 03 - Build Boost Library - Third Part Execute b2.png
(635.7 KiB) Not downloaded yet
Step 03 - Build Boost Library - Second Part Execute boostrap.png
(553.31 KiB) Not downloaded yet
Step 03 - Build Boost Library - First Part.png
(794.41 KiB) Not downloaded yet
Step 02 - Eclipse Installation Details - Second Part.png
(55.3 KiB) Not downloaded yet
Step 02 - Eclipse Installation Details - First Part.png
(241.61 KiB) Not downloaded yet
Step 01 - API Download.png
(85.24 KiB) Not downloaded yet
ramSe7en
Posts: 5
Joined: 13 Feb 2014, 17:40

Re: Building library in Ubuntu (Eclipse)

Postby ramSe7en » 18 Mar 2014, 16:06

Hi,

Thanks for the reply.

I was using "Kepler" version of Eclipse, even though it shouldn't make any difference, I downloaded Juno version & made sure the CDT versions are same as yours from the screenshot.

But the end result didn't change :(

However, there is 1 difference I see from your screen shots. download/file.php?id=280

If you see in the screenshot, the excluded folders are visible, but with a grey mask or something. But they are VISIBLE in the project explorer.
But in my case, those folders are totally invisible in the project explorer.
http://gyazo.com/86b217917168bfa97f39fc984234e92a

Also the way of excluding resource is different in the eclipse. As per the doc :
In the Project Explorer panel, perform the following exclusions (to do it, right-click on the project node and select Resource configuration > Exclude from build or Properties in the popup menu)

Where as in my case :
Project Properties -> Resource -> Resource Filters
http://gyazo.com/8d213674e35ea62e6c520850b684d9f0

Because the other way mentioned in the doc is not available in my Eclipse:
http://gyazo.com/7d4c2130b7535dfe640871ba0a5ab583

I don't think these could be the reasons for the issues which I am facing. Since these are the only difference I am having in my environment, mentioning these. :(

Thanks.
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: Building library in Ubuntu (Eclipse)

Postby MBagnati » 19 Mar 2014, 00:45

Hi,
...we have the same API files...
...we have the same Eclipse and the same CDT ...
...we do the same steps...

:( but we have different results :(

I think that there is another variable to check.
I am using a Pc with Linux 32bit. Could be that you have a Linux 64bit?
If it is, you must note that GCC changes its behaviour on a 64bit version, and requires the -fPIC to make a shared library.
In this case, please take at look at this link http://linuxtortures.blogspot.it/2012/03/shared-libraries-with-eclipse-on-8664.html section C. Making and compiling Shared libraries
ramSe7en
Posts: 5
Joined: 13 Feb 2014, 17:40

Re: Building library in Ubuntu (Eclipse)

Postby ramSe7en » 24 Mar 2014, 14:16

Hi,

You are right, my system is running Ubuntu 13.10 64 bit. All other things (G++, Eclipse & JDK) are also 64 bit.

I enabled -fPIC option in Eclipse as mentioned in that link. But it still has the same error :
./Util/md5/md5.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

By any chance this could be due to boost library?! Because I didn't give any extra compiler options while building boost. I just used the script provided in the library.

If this doesn't resolve, will I have to fall back to 32 bit environment? :(

Thanks.
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: Building library in Ubuntu (Eclipse)

Postby MBagnati » 25 Mar 2014, 19:08

Hi,
API was compiled in the past for a MAC 64bit environment (topic http://www.smartfoxserver.com/forums/viewtopic.php?f=34&t=16120) but I have no notice about anyone that uses Linux 64bit. I am starting to create a 64bit environment on my computer to investigate the issue to look for a solution. I need a little of time to create the environment and to debug. I will notify you about the question as soon as possibile.
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: Building library in Ubuntu (Eclipse)

Postby MBagnati » 30 Mar 2014, 10:47

Hi,
I have created a 64bit environment on my PC based on Linux Ubuntu 13.10 with latest Eclipse Kepler.
I have got Eclipse from website http://www.eclipse.org
I have got g++ by this terminal command apt-get install g++
I have got Java (required by Eclipse) by this terminal command sudo apt-get install openjdk-7-jre
The attached images "Ubuntu Version", "Eclipse Version - Image A", "Eclipse Version - Image B" show their versions.

Then I have downloaded C++ API from SmartFoxServer website and following instructions I have built them: first I have build Boost library then the Zlib and finally the API.
All actions have been completed without errors as you can see in screenshot "API Build - Image A" and "API Build - Image B"

Can you give me additional info about your problem to understand why we have different results?
Attachments
API Build - Image B.png
(214.5 KiB) Not downloaded yet
API Build - Image A.png
(204.64 KiB) Not downloaded yet
Eclipse Version - Image B.png
(275.82 KiB) Not downloaded yet
Eclipse Version - Image A.png
(300.22 KiB) Not downloaded yet
Ubuntu Version.png
(2 MiB) Not downloaded yet

Return to “SFS2X C++ API”

Who is online

Users browsing this forum: No registered users and 32 guests