Author Topic: Really Weird Code::Blocks Compiling Error  (Read 15348 times)

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Really Weird Code::Blocks Compiling Error
« on: February 05, 2011, 06:19:17 am »
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.
« Last Edit: February 05, 2011, 07:37:22 am by Wander »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(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!]

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Really Weird Code::Blocks Compiling Error
« Reply #2 on: February 05, 2011, 08:10:15 am »
Sorry, but that didn't help. :/

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7590
    • My Best Post
Re: Really Weird Code::Blocks Compiling Error
« Reply #3 on: February 05, 2011, 04:43:10 pm »
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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Really Weird Code::Blocks Compiling Error
« Reply #4 on: February 05, 2011, 04:46:25 pm »
So you mean post all of the errors?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Really Weird Code::Blocks Compiling Error
« Reply #5 on: February 05, 2011, 05:59:36 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.

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Really Weird Code::Blocks Compiling Error
« Reply #6 on: February 05, 2011, 07:22:33 pm »
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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Really Weird Code::Blocks Compiling Error
« Reply #7 on: February 05, 2011, 07:28:43 pm »
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 !

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Really Weird Code::Blocks Compiling Error
« Reply #8 on: February 05, 2011, 07:43:30 pm »
Code
[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:

Code
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()'

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Really Weird Code::Blocks Compiling Error
« Reply #9 on: February 05, 2011, 08:05:37 pm »
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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Really Weird Code::Blocks Compiling Error
« Reply #10 on: February 05, 2011, 08:08:16 pm »
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 !

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Really Weird Code::Blocks Compiling Error
« Reply #11 on: February 05, 2011, 08:21:33 pm »
Quote
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.

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

Quote
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 !

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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Really Weird Code::Blocks Compiling Error
« Reply #12 on: February 05, 2011, 09:44:44 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.

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Really Weird Code::Blocks Compiling Error
« Reply #13 on: February 05, 2011, 09:49:17 pm »
Quote
I 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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Really Weird Code::Blocks Compiling Error
« Reply #14 on: February 05, 2011, 10:08:00 pm »
Quote
I 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).

Offline Wander

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Really Weird Code::Blocks Compiling Error
« Reply #15 on: February 05, 2011, 10:10:44 pm »
Quote
Neither the OS, the compiler, your code or your computer are related to C::B !
Those were examples. The whole point was to express that I had no clue.

Quote
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).
So am I gonna get banned for forgetfulness? I'm only human.