Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 06-17-2013, 07:58 PM   #1
Baseband Member
 
Join Date: Jan 2013
Location: Canada
Posts: 69
Default C++ Compile error

when i type this code:
Code:
#include <iostream> 
 using namespace std;
int main()
{
 cout << "Hello world!" << endl; 
return 0; 
}
into code::blocks or C++ visual studio 2010 (using the code it generates by default)

i get this error:

||=== Hello World, Debug ===|
ld.exe||cannot find -lSDL_image|
||=== Build finished: 1 errors, 0 warnings (0 minutes, 6 seconds) ===|

can anyone tell me what this means and how i fix it? ive tried uninstalling and reinstalling and it didnt work
__________________

jaywash is offline   Reply With Quote
Old 06-18-2013, 04:52 AM   #2
Fully Optimized
 
BikerEcho's Avatar
 
Join Date: Feb 2011
Location: Denmark
Posts: 4,013
Default Re: C++ Compile error

i am not a programmer at all, but i have had some basics C++ and C# lessons when i was doing my education.

i don't know if this helps, but i think there is suppose to be a space between "int main" and "()"
so try this "int main ()"
__________________

__________________
MOBO: Asus Maximus 6 Hero - GPU: Gigabyte GTX 980ti xtreme - CPU: I7-4770K - PSU: Corsair AX760
RAM: Corsair Vantage 2x4GB - SSD: Samsung 840 EVO 512 + LiteOn LCS-256 - Case: NZXT H440
BikerEcho is offline   Reply With Quote
Old 06-18-2013, 01:18 PM   #3
In Runtime
 
Join Date: Feb 2013
Location: UK
Posts: 156
Default Re: C++ Compile error

This is a 'Linker' error, not a compiler error. As such, there is nothing wrong with your code block above. The error you're getting refers to an external resource which your application is attempting to link with called SDL_image.

Linking is the build stage which takes place after compilation. Your code is compiled into individual objects (typically libraries) and then these objects are linked together. Ultimately these will culminate in either static linking which bundle the code directly into the final executable or shared objects (.so on linux) / dynamically linked libraries (.dll on windows) where the executable reads in the libraries as and when required.

I'm guessing you took your starting point from an example project somewhere, by copying that project you've also inherited the linker settings. I don't use visual studio, so I can't give you precise directions for your UI, but I imagine if you right click your project and go to properties - then look for Linker settings - you'll find a reference somewhere to something called libSDL_image.dll or similar. Remove that reference and then try to build your project again.

As a side note, this is one of the problems I find with beginners using 'intelligent' IDEs. They are supposed to make the work easier to do, but ultimately lead to FAR more 'errors' due to their misconfiguration and they'll be much harder to find solutions for. If you can, take any single-file code samples and just run with gcc or other compiler which works outside of an IDE (integrated development environment, i.e. visual studio/eclipse/netbeans etc.). This should make your life much easier in future.

Hope that helps,
Michael.
_michaelm is offline   Reply With Quote
Old 06-20-2013, 10:52 AM   #4
Baseband Member
 
Join Date: Jan 2013
Location: Canada
Posts: 69
Default Re: C++ Compile error

Quote:
Originally Posted by _michaelm View Post
This is a 'Linker' error, not a compiler error. As such, there is nothing wrong with your code block above. The error you're getting refers to an external resource which your application is attempting to link with called SDL_image.

Linking is the build stage which takes place after compilation. Your code is compiled into individual objects (typically libraries) and then these objects are linked together. Ultimately these will culminate in either static linking which bundle the code directly into the final executable or shared objects (.so on linux) / dynamically linked libraries (.dll on windows) where the executable reads in the libraries as and when required.

I'm guessing you took your starting point from an example project somewhere, by copying that project you've also inherited the linker settings. I don't use visual studio, so I can't give you precise directions for your UI, but I imagine if you right click your project and go to properties - then look for Linker settings - you'll find a reference somewhere to something called libSDL_image.dll or similar. Remove that reference and then try to build your project again.

As a side note, this is one of the problems I find with beginners using 'intelligent' IDEs. They are supposed to make the work easier to do, but ultimately lead to FAR more 'errors' due to their misconfiguration and they'll be much harder to find solutions for. If you can, take any single-file code samples and just run with gcc or other compiler which works outside of an IDE (integrated development environment, i.e. visual studio/eclipse/netbeans etc.). This should make your life much easier in future.

Hope that helps,
Michael.
Thanks! everything works fine now, I can finally study it properly thank you so much.
jaywash is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 10:01 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0