d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Cross Platform Compiling
Add Reply New Topic New Poll
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Feb 14 2014 06:12pm
Is a bitch.

I'm trying to figure out how I can take a program that I've developed on OSX (32bit) and compile it on CentOS 6.5.. but I can't find much (understandable) documentation about this.
I know that I'll have to include any 3rd party library source files I've used and the necessary compile flags to go with em, if applicable. Here's a list of the libraries I used:
  • htmlcxx
  • boost 1.55
  • pugixml
  • iconv
  • INIReader
  • libcurl

Linker flags taken directly from xcode on OSX:

Code
-lcurl -liconv -L/Users/dillan/Development/Libraries/boost/lib -lboost_regex -lboost_system -lboost_filesystem


The compiler im using on OSX is llvm 5.0. Should I use this same compiler when trying to cross compile onto CentOS?

I dont have any experience with this so any advice / help is appreciated. :3







Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 15 2014 01:02am
Your question is a bit weird, are you trying to take your source and compile it on another distro or are you trying to compile a binary from OSX that will run on other platforms.

Personally I would just install your distro into a VM and take your code and compile in the vm. Setting up a cross compile toolchain can be a real bitch.

You also do not need to use the same compiler, as long as you can link against your libraries anything will do.
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Feb 15 2014 01:16am
Quote (AbDuCt @ Feb 14 2014 11:02pm)
Your question is a bit weird, are you trying to take your source and compile it on another distro or are you trying to compile a binary from OSX that will run on other platforms.

Personally I would just install your distro into a VM and take your code and compile in the vm. Setting up a cross compile toolchain can be a real bitch.

You also do not need to use the same compiler, as long as you can link against your libraries anything will do.


Yeah I'm not real familiar with the topic so I'm sure my questions seemed a bit off.

I'm trying to take my source and compile it on other distros. Basically, I wrote a crawler on my macbook and now I'm trying to port it over to CentOS so I can run it on my server.

What I've done so far is taken the source and put it on the server. I've been trying to compile it using g++ but it keeps dumping a shit ton of boost syntax errors.

I have managed to include and compile the other libraries though I believe..
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 15 2014 01:18am
Quote (SelfTaught @ Feb 15 2014 03:16am)
Yeah I'm not real familiar with the topic so I'm sure my questions seemed a bit off.

I'm trying to take my source and compile it on other distros. Basically, I wrote a crawler on my macbook and now I'm trying to port it over to CentOS so I can run it on my server.

What I've done so far is taken the source and put it on the server. I've been trying to compile it using g++ but it keeps dumping a shit ton of boost syntax errors.

I have managed to include and compile the other libraries though I believe..


Well... can't help you much without knowing what is error now can we lol.
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Feb 15 2014 01:26am
Quote (AbDuCt @ Feb 14 2014 11:18pm)
Well... can't help you much without knowing what is error now can we lol.


Derp, good point.

Here's the command im using to compile incase it's any help:

Code
g++ -I /usr/include/boost -I ./html/ -I ./pugixml/ -I ./cpp/ -I ../include/ -L../lib -std=c++0x -lcurl -liconv -l boost_system -l boost_regex -o {source files}


Here's just a few errors it's dumping..

Code
/usr/include/boost/log/attributes/attribute_name.hpp: At global scope:
/usr/include/boost/log/attributes/attribute_name.hpp:70: error: ‘BOOST_CONSTEXPR’ does not name a type
/usr/include/boost/log/attributes/attribute_name.hpp:99: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_name.hpp:106: error: expected ‘;’ before ‘bool’
/usr/include/boost/log/attributes/attribute_name.hpp:106: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_name.hpp:114: error: expected ‘;’ before ‘bool’
In file included from /usr/include/boost/log/attributes/attribute_set.hpp:24,
from /usr/include/boost/log/sources/basic_logger.hpp:35,
from main.h:48,
from auth.cpp:9:
/usr/include/boost/log/attributes/attribute_name.hpp:143: error: only declarations of constructors can be ‘explicit’
/usr/include/boost/log/attributes/attribute_name.hpp:150: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_name.hpp:156: error: expected ‘;’ before ‘id_type’
/usr/include/boost/log/attributes/attribute_name.hpp:156: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_name.hpp:165: error: expected ‘;’ before ‘string_type’
/usr/include/boost/log/attributes/attribute_name.hpp: In member function ‘boost::log::v2s_mt_posix::attribute_name::operator bool() const’:
/usr/include/boost/log/attributes/attribute_name.hpp:143: error: ‘const class boost::log::v2s_mt_posix::attribute_name’ has no member named ‘operator!’
In file included from /usr/include/boost/log/attributes/attribute_set.hpp:25,
from /usr/include/boost/log/sources/basic_logger.hpp:35,
from main.h:48,
from auth.cpp:9:
/usr/include/boost/log/attributes/attribute.hpp: At global scope:
/usr/include/boost/log/attributes/attribute.hpp:79: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:96: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:101: error: expected ‘;’ before ‘attribute’
/usr/include/boost/log/attributes/attribute.hpp:101: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:108: error: expected ‘;’ before ‘explicit’
/usr/include/boost/log/attributes/attribute.hpp:108: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:113: error: expected ‘;’ before ‘attribute’
/usr/include/boost/log/attributes/attribute.hpp:113: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:122: error: expected ‘;’ before ‘attribute’
/usr/include/boost/log/attributes/attribute.hpp:122: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:129: error: expected ‘;’ before ‘attribute’
/usr/include/boost/log/attributes/attribute.hpp:129: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:135: error: only declarations of constructors can be ‘explicit’
/usr/include/boost/log/attributes/attribute.hpp:140: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:146: error: expected ‘;’ before ‘attribute_value’
/usr/include/boost/log/attributes/attribute.hpp:151: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:153: error: expected ‘;’ before ‘protected’
/usr/include/boost/log/attributes/attribute.hpp:157: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:163: error: expected ‘;’ before ‘void’
/usr/include/boost/log/attributes/attribute.hpp:163: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute.hpp:165: error: expected ‘;’ before ‘template’
/usr/include/boost/log/attributes/attribute.hpp: In member function ‘boost::log::v2s_mt_posix::attribute::operator bool() const’:
/usr/include/boost/log/attributes/attribute.hpp:135: error: ‘const class boost::log::v2s_mt_posix::attribute’ has no member named ‘operator!’
/usr/include/boost/log/attributes/attribute.hpp: At global scope:
/usr/include/boost/log/attributes/attribute.hpp:172: error: expected initializer before ‘BOOST_NOEXCEPT’
In file included from /usr/include/boost/log/sources/basic_logger.hpp:35,
from main.h:48,
from auth.cpp:9:
/usr/include/boost/log/attributes/attribute_set.hpp:56: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_set.hpp:63: error: expected ‘;’ before ‘operator’
/usr/include/boost/log/attributes/attribute_set.hpp:63: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_set.hpp:167: error: ‘BOOST_CONSTEXPR’ does not name a type
/usr/include/boost/log/attributes/attribute_set.hpp:168: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_set.hpp:169: error: expected ‘;’ before ‘iter’
/usr/include/boost/log/attributes/attribute_set.hpp:169: error: expected ‘;’ before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_set.hpp:172: error: expected ‘;’ before ‘template’
/usr/include/boost/log/attributes/attribute_set.hpp:173: error: expected initializer before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_set.hpp:181: error: expected initializer before ‘BOOST_NOEXCEPT’
/usr/include/boost/log/attributes/attribute_set.hpp:183: error: expected initializer before ‘BOOST_NOEXCEPT’


This post was edited by SelfTaught on Feb 15 2014 01:26am
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 15 2014 01:32am
I'm not sure exactly what that problem is from those logs (might be because I've never used/had to compile boost), but here is someone who made a script and a how-to to install gcc and boost if it helps any.

http://joelinoff.com/blog/?p=1003

This post was edited by AbDuCt on Feb 15 2014 01:33am
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Feb 15 2014 01:39am
Quote (AbDuCt @ Feb 14 2014 11:32pm)
I'm not sure exactly what that problem is from those logs (might be because I've never used/had to compile boost), but here is someone who made a script and a how-to to install gcc and boost if it helps any.

http://joelinoff.com/blog/?p=1003


That looks helpful.. thx. I'll read it and try getting this to compile some more tomorrow.

This post was edited by SelfTaught on Feb 15 2014 01:40am
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 15 2014 01:42am
Building cross-compilers is fun...

http://stackoverflow.com/questions/1775267/how-to-cross-compile-from-mac-os-x-to-linux-x86

Might be a little outdated, but a little googlefu pulled up that stackoverflow question. The answerer linked some resources on how to build them. Useful, perhaps?
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Feb 19 2014 11:48pm
Well, after a shit ton of compiling / trial & error I was finally able to successfully compile
What I did might have taken more work than necessary but I did get it working.

What I did was:
  • Installed CentOS SDW in VrtualBox
  • Installed all library dependencies
  • Created a project in Eclipse CDT & imported my project source
  • Added include / lib directories & linker flags
  • And.. compiled


This post was edited by SelfTaught on Feb 19 2014 11:53pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 20 2014 02:59am
Quote (SelfTaught @ Feb 20 2014 01:48am)
Well, after a shit ton of compiling / trial & error I was finally able to successfully compile
What I did might have taken more work than necessary but I did get it working.

What I did was:
  • Installed CentOS SDW in VrtualBox
  • Installed all library dependencies
  • Created a project in Eclipse CDT & imported my project source
  • Added include / lib directories & linker flags
  • And.. compiled


Grats. That's the easiest way to cross compile really and once you have it setup you don't need to touch it again. It would of taken a lot longer trying to get cross compile tool chains working on your mac os.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll