?
Solved

DevC++ linker errors

Posted on 2011-10-20
8
Medium Priority
?
379 Views
Last Modified: 2012-05-12
Hello all,

Im trying to compile a c program in DevC++ but im getting Linker errors of the sort:
[Linker error] Undefined reference to 'image'..
Image is a variable defined in a seperate header file.. Can someone tell me how to link .c to .h files in DevC++??

Thanks
0
Comment
Question by:oggiemc
  • 4
  • 3
8 Comments
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37003185
I don't understand your question.  How are you trying to include the file now?

Perhaps you mean
# include <filename.h>

But I don't know from what you've shared so far.

Suggestion: Click Request attention and ask a moderator to add this question to the C++ zone (if you don't get an answer in a few minutes).  You can also ask the moderator to remove the JavaScript zone.
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37003188
Or

# include "filename.h"
0
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 500 total points
ID: 37003196
In C,
# include "filename.h"
Looks for a file called "filename.h" in the local folder.
but
# include <filename.h>
Looks for a file "filename.h" in the compiler's folders.  (That's not strictly correct but close enough.)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 24

Assisted Solution

by:fridom
fridom earned 500 total points
ID: 37004743
a linker error has nothing to do with the inclusion of any header.
A linker looks for Symbols in files and this Symbols are often kept in libraries.
Therefor one has to tell the linker to which libraries to link.

the usual switch for that is -L path/to_llib -ltheliblibrary.

To get anything working with C one has to include the proper headers for
making symbols known during runtime and the libraries which contain symbols  of "build functionality".

image is therefor in some library you do not have linked against.

in Dev C++ must be  a tab in which you can add paths to libraries and names of libraries to link against.

That is what you have to do

a command line invocation on Linux may look like
gcc -Ipath_to_include_files -Lpath_to_libraries file_to_compile.c -llibrary_to_link_against.

0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 37006049
Fridom, the way I read the question is that the linker isn't finding a symbol created by the author.
0
 
LVL 24

Expert Comment

by:fridom
ID: 37006466
Well in that case the order of the files may be important. He than has to see that the file  with the
missed symbol is at the end of the  "chain" but that should be taken care of in the IDE AFAIKT.
0
 

Author Comment

by:oggiemc
ID: 37007736
Hello all..Perhaps i should have included the files to save confusion..Please see attached..When i try running example.c i get multiple linker errors..Any ideas?? Thanks
program.zip
0
 
LVL 24

Expert Comment

by:fridom
ID: 37187817
Well you have to remove them one by one.  A linker is mostly unable to recover after the first error.  And so solving one after the other
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question