Thread: Linker Problems

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    3

    Linker Problems

    Hi,
    I'm trying to use the ImageMagick libraries in a project and I'm getting lots of Unresolved External Symbol problems

    I'm writing it in C, in MSVC and I'm pretty sure the code's all ok because at the moment I'm only trying to work one of their samples. The includes look like this:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    #include <magick/api.h>
    and those are all in the right places, and the list of external dependencies contains a long list of .h files which contain all the functions I'm using.

    This is probably just because I don't really know what I'm doing where MSVC is concerned, but I couldn't find anything on search so I'm wondering if there's anything really obvious I'm doing wrong?

    thanks for any help

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I'm wondering if there's anything really obvious I'm doing wrong?
    Well you're doing a few things wrong:
    1) You didn't read the Announcements before posting.
    2) You didn't use [code] tags, which leads us back to #1.
    3) You didn't post your linker errors, which leads us back to #1.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    210
    You probably forgot to tell your linker to link the ImageMagick library into your executable. Functions are not contained in .h files. Their headers are. You still need the library, otherwise the symbols introduces in those headers cannot be found.

    Quote Originally Posted by quzah
    2) You didn't use [code] tags, which leads us back to #1.
    I can't see any actual code.
    Last edited by Nyda; 09-13-2004 at 11:04 AM.

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    3
    I don't see anything in the anouncements which relates to what I posted, but fair enough.

    The errors are just
    main.obj : error LNK2001: unresolved external symbol _EdgeImage

    repeated for all the ImageMacick functions.

    Thanks for the advice Nyda, I'll try and have a look at that

    Edit: OK, got it sorted. Thanks again
    Last edited by Jason84; 09-13-2004 at 12:02 PM.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Nyda
    You probably forgot to tell your linker to link the ImageMagick library into your executable. Functions are not contained in .h files. Their headers are. You still need the library, otherwise the symbols introduces in those headers cannot be found.

    I can't see any actual code.
    I can.
    Quote Originally Posted by Jason84
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    #include <magick/api.h>
    That isn't "actual code"?

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Apr 2004
    Posts
    210
    Quote Originally Posted by quzah
    I can.

    That isn't "actual code"?

    Quzah.
    If you want to be picky about it, no. It won't be compiled.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Nyda
    If you want to be picky about it, no. It won't be compiled.
    If I want to be picky about it, which I did, it will compile:
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    /* #include <magick/api.h> I don't have this, so I'll exclude it. */
    gcc -c yesitwill.c -Wall

    It did, and it does compile. It is "real code". Just because you don't feel like compiling it, doesn't make the above "not real code". It is. It does compile. It will make an object file. It did make an object file. My compiler believes it is "real code".

    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Registered User
    Join Date
    Apr 2004
    Posts
    210
    Quote Originally Posted by quzah
    It does compile. It will make an object file. It did make an object file. My compiler believes it is "real code".
    It is a preprocessor command. Your compiler won't see anything of it. It will see the resolved header contents, but not the include.

    Anyway, I don't see why you must be picky about a few lines of preprocessor commands without giving the OP at least a slightest hint about what might be wrong (which was very obvious). I don't need a reply.

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It is a preprocessor command. Your compiler won't see anything of it. It will see the resolved header contents, but not the include.
    Oh really?
    Code:
    /*myheader.c*/
    #include "myheader.h"
    Compile and execute:

    gcc -o myheader myheader.c
    ./myheader
    Code:
    /*myheader.h*/
    #include <stdio.h>
    int main( void )
    {
        printf("So you're trying to say just because it's a header, it's not real code?\n");
        return 0;
    }
    My compiler definately will see it. Just because you call it a ".h", doesn't mean nothing else happens. If you don't believe me, try the above. You're trying to tell me that the compiler doesn't parse header files? What? That's pretty amusing.

    The fact that you're wrong aside, I can't believe you're advocating not using [code] tags. What a tool.

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> I don't need a reply.
    Oh, yes.

    >> It is a preprocessor command.
    So if the preprocessor parses it, then it isn't code?

    >> Your compiler won't see anything of it. It will see ...
    Your argument has collapsed under it's own weakness. And you know as well as anyone else that this is not even worth debating.

    >> I don't see why you must be picky...
    There's nothing picky about informing a new board member on the board's policies.

    >> ...hint about what might be wrong
    I saw 3 "hints" as to how the OP's post could be improved - which helps readers help the OP.

    >> (which was very obvious)
    And I'm sure that if you had not given the OP the information he needed, quzah would have.

    gg

  11. #11
    Registered User
    Join Date
    Apr 2004
    Posts
    210
    Come on. You are not even using quote tags now.

    Quote Originally Posted by Codeplug
    >> Your compiler won't see anything of it. It will see ...
    Your argument has collapsed under it's own weakness. And you know as well as anyone else that this is not even worth debating.
    You are so right. It is not worth debating at all. That is why I didn't need a flaming reply.

    Quote Originally Posted by Codeplug
    >> I don't see why you must be picky...
    There's nothing picky about informing a new board member on the board's policies.
    A rather rude idea of "informing".

    Quote Originally Posted by Codeplug
    >> (which was very obvious)
    And I'm sure that if you had not given the OP the information he needed, quzah would have.
    More likely the original poster would have read the reply and not even considered visiting this board again. But then again, I'm more or less new here too, so you'll probably just tell me to shut up and stop complaining until I get a decent postcount. Oh well. That's exacty what I'll do now.

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    But then again, I'm more or less new here too, so you'll probably just tell me to shut up and stop complaining until I get a decent postcount. Oh well. That's exacty what I'll do now.
    Noone cares what your post count is. What they do care about is if you actually pay attention to the forum rules. Now, if you don't read them, you can't very well pay attention to them, can you? The point is, you were wrong and you were called on it. It happens. I didn't flame you, you would know if I had.

    The main point was, if you don't post enough information, how can we help? In otherwords, if you're getting an error, don't say "I'm getting an error, help!", say "I'm getting this error:" and then show us what it is. This should be covered in the Announcements, but isn't clarified enough. I'll see if we can't get it modified to spell it out clearer.

    As to your "you aren't even using quote tags" remark, had you read the Announcements, you'd have seen that the only tags of importance are [code] tags, which is why there's an entire seperate announcement for it.

    Quzah.
    Hope is the first step on the road to disappointment.

  13. #13
    Registered User
    Join Date
    Apr 2004
    Posts
    210
    Quote Originally Posted by quzah
    Noone cares what your post count is.
    People in General Discussions obviously disagree.

    Who cares if quotes are in the announcements or not - I didn't complain about it, just pointed it out.
    On another matter, I strongly believe you got confused with me and the original poster somewhere in the middle of your post.
    If you feel you picked the right kind of language I'll just assume we're communication-incompatible and leave it at that.

    That said, I'm not going to discuss this anymore because I feel it's not even worth half the trouble we're taking here.
    Last edited by Nyda; 09-14-2004 at 12:29 PM.

  14. #14
    Rules are of importance, and induce their cause.

    Reply #3 states after the recent editing at 11:02 AM PST Yesterday:
    Quote Originally Posted by Jason84
    Edit: OK, got it sorted. Thanks again
    I believe that leads us to the illation of this topic nevertheless.
    Last edited by Stack Overflow; 09-14-2004 at 12:51 PM.
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  15. #15
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    @ stack overflow: i see jason84 and nyda have met quazah.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker errors
    By jw232 in forum C++ Programming
    Replies: 3
    Last Post: 06-12-2009, 12:56 PM
  2. Linker problem... no idea
    By cyreon in forum C Programming
    Replies: 2
    Last Post: 04-03-2009, 02:53 PM
  3. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  4. winsock linking problems
    By Calef13 in forum Windows Programming
    Replies: 2
    Last Post: 08-29-2007, 08:54 AM
  5. MSVis-Studio C++ libraries and linker errors
    By kellydj in forum Windows Programming
    Replies: 10
    Last Post: 03-12-2002, 02:03 PM