System: MacOsX 10.6.8
gcc compiler: i686-apple-darwin10-gcc-4.2.1: no input files
PROCEDURE:
- Downloaded Src_xml2abc_2013_03_26.zip and unpacked
- Downloaded boost_1_53_0.tar.gz and unpacked. Then, placed the folder inside the src_Moritz2 directory.
I tried to build Moritz 2 with "gcc" instead of "g++" also and I've got a similar result, a lot of "undefined reference to ..."
Than I searched a little bit in the mailing-list "SourceForge.net: MinGW - Minimalist GNU for Windows". This is one of the 2 gnu-compiler distributions for windows (the other one is cyg-win). Here I found a mail-worm "[Mingw-users] Undefined references when linking with mingw32-gcc"(I have added the last reply).
The take-home-messages are:
1. You can use "gcc" to compile the sources but you have to use "g++" to link the object-files.
2. On the other side you can use "g++" also to compile the cpp-sources.
Best regards,
Eckard.
Email Archive: mingw-users (read-only) Re: [Mingw-users] Undefined references when linking with mingw32-gcc
From: Earnie earnie@us... - 2011-12-18 15:20 I've read all the posts but choose to answer the original mail.
First I will say DO NOT TOP POST.
Second, trim the parts of the quoted mail you're not responding to.
More below
Sultan Saini wrote:
Hello,
I'm trying to build a small jni dll with mingw gcc and am having trouble
during the linking step of the build.
The linker command is thus:
/c/MinGW/bin/mingw32-gcc.exe -w -fPIC -lstdc++ -shared -mwindows
-LC:/MinGW/lib/glut -LC:/MinGW/lib/GLU -LC:/MinGW/lib/GL -lm
-LC:/MinGW/lib/glib-2.0 -lopengl32 -lglu32 -lglut32 -lglib-2.0
build/gl2ps.o build/gl2psjni.o build/mathml2ps.o -o build/gl2psjni.dll
1) Command line order matters for the library specification. Libraries to resolve references in objects must follow the object specification and not precede it.
2) For C++ code you do to use G++ and not GCC for the link step.
3) Do not include the standard libraries like libstdc++ in the link step.
4) -lm is meaningless.
System: MacOsX 10.6.8
gcc compiler: i686-apple-darwin10-gcc-4.2.1: no input files
PROCEDURE:
- Downloaded Src_xml2abc_2013_03_26.zip and unpacked
- Downloaded boost_1_53_0.tar.gz and unpacked. Then, placed the folder inside the src_Moritz2 directory.
run the gcc compiler:
gcc diverse/cpp/.cpp Moritz2/cpp/.cpp MuLanPa/cpp/.cpp MuLanPa/process/cpp/.cpp tool_xml/.cpp tinyxml/.cpp -Idiverse/h -IMoritz2/h -IMuLanPa/h -IMuLanPa/process/h -Itool_xml -Itinyxml -Iboost_1_53_0 -D TIXML_USE_STL -o a.out
*Note: using "-D NO_SYSTEM_FOR_FOLDERCREATE" is not compatible with Mac
using "-D SYSTEM_FOR_FOLDERCREATE" seems to give the same errors.
OUTPUT: begins with
Undefined symbols:
"std::_List_node_base::unhook()", referenced from:
std::list<std::basic_string<char, std::char_traits<char="">, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char="">, std::allocator<char> > > >::_M_erase(std::_List_iterator<std::basic_string<char, std::char_traits<char="">, std::allocator<char> > >)in ccZGlK7x.o
std::list<std::basic_string<char, std::char_traits<char="">, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char="">, std::allocator<char> > > >::_M_erase(std::_List_iterator<std::basic_string<char, std::char_traits<char="">, std::allocator<char> > >)in cchxaxUH.o
std::list<boost::spirit::classic::tree_match<char const*,="" boost::spirit::classic::node_iter_data_factory<char="">, boost::spirit::classic::nil_t>, std::allocator<boost::spirit::classic::tree_match<char const*,="" boost::spirit::classic::node_iter_data_factory<char="">, boost::spirit::classic::nil_t> > >::_M_erase(std::_List_iterator<boost::spirit::classic::tree_match<char const*,="" boost::spirit::classic::node_iter_data_factory<char="">, boost::spirit::classic::nil_t> >)in ccOtGcB8.o
It was all my fault.
Just replaced gcc --> g++
Post is solved. Should I do next time in "bugs &requests" section?
Hello Juan.
I tried to build Moritz 2 with "gcc" instead of "g++" also and I've got a similar result, a lot of "undefined reference to ..."
Than I searched a little bit in the mailing-list "SourceForge.net: MinGW - Minimalist GNU for Windows". This is one of the 2 gnu-compiler distributions for windows (the other one is cyg-win). Here I found a mail-worm "[Mingw-users] Undefined references when linking with mingw32-gcc"(I have added the last reply).
The take-home-messages are:
1. You can use "gcc" to compile the sources but you have to use "g++" to link the object-files.
2. On the other side you can use "g++" also to compile the cpp-sources.
Best regards,
Eckard.
Last edit: Eckard Klotz 2013-04-03