News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Really Weird Code::Blocks Compiling Error

Started by Wander, February 05, 2011, 06:19:17 AM

Previous topic - Next topic

Wander

Okay! So this is the weirdest compiler error I have ever seen. I have already gone through my code of about 30 lines many times to make sure its correct and it is. Also, I don't believe such a small code could generate over 50 errors.

Here is what is happening. I closed Code::Blocks today before leaving the house and it was working perfectly. After coming home, I opened the laptop and started up Code::Blocks. It told me that it couldn't open up my project that I had saved in the workspace, I took this as a grain of salt. So then I manually opened up the project and edited a bit of code and hit Build and Run. Here is the weird part.

It compiled perfectly and then when it was linking my project it came up with over 50 errors. All the likes of which I haven't seen. Here are some examples:

||warning: auto-importing has been activated without --enable-auto-import specified on the command line.|
undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'|
undefined reference to `std::string::c_str() const'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::cout'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'|
undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'|
undefined reference to `std::cout'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'|
undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'|
undefined reference to `std::allocator<char>::allocator()'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'|
undefined reference to `std::allocator<char>::~allocator()'|
undefined reference to `std::allocator<char>::~allocator()'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::cout'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'|
undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'|
undefined reference to `std::cout'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'|
undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|


That is not even the majority of them, but I don't have time or patience to post them all, but if you need more of the errors, just tell me and I will post them. Anything to fix this. I need to finish my project or I don't get payed. :/

I'm just shooting birds here, but it seems to me that it isn't even recognizing the language? It keeps saying cout is undefined....

EDIT: After installing Wine to my Linux distribution, I tried to run the same code that is compatible with Linux and I got the EXACT same errors.

oBFusCATed

(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Wander


stahta01

Quote from: Wander on February 05, 2011, 08:10:15 AM
Sorry, but that didn't help. :/

If you post the full build log on a site with experts on using YOUR compiler they should be about to say if the command is right or wrong.
This site is for Code::Blocks issues; you might try posting the full rebuild log here to see if an Code::Blocks related problem or simple compiler or OS related problem is noticed.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Wander


Jenna

Quote from: Wander on February 05, 2011, 04:46:25 PM
So you mean post all of the errors?
Not necessary all errors, but the full commandline sent to the compiler.
And of course the OS, the compiler (and version) and the C::B version.

Wander

Alright, so where do I find the command line. After turning on the command line thing in the settings nothing showed up extra when I compiled. I tried to find it in View but to no avail.

Jenna

If you really have turned on full commandline logging, you see it in the "Build log".

And please use code-tags to display code and logs or similar content !

Wander

[100.0%] mingw32-gcc-4.4.0.exe -LC:\SFML-1.6\lib  -o BinObj\bin\Debug\tGUI.exe BinObj\obj\Debug\tGUI.o BinObj\obj\Debug\main.o   -lmingw32 -lsfml-system -lsfml-window -lsfml-graphics -static-libgcc 
f:/mingw 4.4/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.


Everything is all errors like I showed you earlier. Errors involving the SFML API and some other stuff I have never heard of such as:

tGUI.o: In function `_tcf_0':
   undefined reference to `std::ios_base::Init::~Init()'
tGUI.o: In function `_static_initialization_and_destruction_0':
   undefined reference to `std::ios_base::Init::Init()'

Jenna

If I see it correctly, you use c++-object files/libraries and try to link them with gcc. That does not work.

Using g++.exe or (most likely) mingw32-g++-4.4.0.exe in your case as linker executable.

Jenna

Note:
A simple web-search would have lead you to the same result.

Not searching (also the web) before asking violates our forum rules !
Be warned !

Wander

QuoteIf I see it correctly, you use c++-object files/libraries and try to link them with gcc. That does not work.

Using g++.exe or (most likely) mingw32-g++-4.4.0.exe in your case as linker executable.

Thanks. That solved it. You have saved me. :D

QuoteNote:
A simple web-search would have lead you to the same result.

Not searching (also the web) before asking violates our forum rules !
Be warned !

As a matter of fact, I did web-search for about an hour before posting here. The problem is that I am not compiler savvy, so I had no idea what to search. The compiler gave me not even the slightest hint of what to search. I had no idea if it was my OS, the compiler, my code, or my computer even. I managed to narrow it down to the compiler or the computer. The point is I did search to no avail. And as I see it that is exactly what a forum is for. Post your problems when you can't find a solution.

Jenna

Quote from: Wander on February 05, 2011, 08:21:33 PM
And as I see it that is exactly what a forum is for. Post your problems when you can't find a solution.
Yes, but our forum/website is not a general programming forum, it's a Code::Blocks forum and dedicated to problems around C::B only.
But Code::Blocks is an IDE, not a compiler or a sdk.
Compiler, toolkit and sdk related questions are beyond the scope of our forum.

Wander

QuoteI had no idea if it was my OS, the compiler, my code, or my computer even.

I didn't know what type of problem it was.

Jenna

Quote from: Wander on February 05, 2011, 09:49:17 PM
QuoteI had no idea if it was my OS, the compiler, my code, or my computer even.

I didn't know what type of problem it was.
Neither the OS, the compiler, your code or your computer are related to C::B !

You also violated our forum rules, by not to tell us anything about the setup you use, and you did not tell anything about this (even not after I asked for it).