none
error LNK2019: unresolved external symbol

    Question

  •  I came across with this err. Please help! what are those err refering to???
    Thanks!

    facecmp.obj : error LNK2019: unresolved external symbol __imp__ilOriginFunc@4 referenced in function _main

    facecmp.obj : error LNK2019: unresolved external symbol __imp__ilEnable@4 referenced in function _main

    facecmp.obj : error LNK2019: unresolved external symbol __imp__iluInit@0 referenced in function _main

    facecmp.obj : error LNK2019: unresolved external symbol __imp__ilInit@0 referenced in function _main

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilDeleteImages@8 referenced in function _frImgLoadFile

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilConvertImage@8 referenced in function _frImgLoadFile

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilLoadImage@4 referenced in function _frImgLoadFile

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilBindImage@4 referenced in function _frImgLoadFile

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilGenImages@8 referenced in function _frImgLoadFile

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilSaveImage@4 referenced in function _frImgSaveFile

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilTexImage@28 referenced in function _frImgSaveFile

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilLoadL@12 referenced in function _frImgLoadMem

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilGetData@0 referenced in function _frImgLoadBound

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilGetInteger@4 referenced in function _frImgLoadBound

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__iluScale@12 referenced in function _frImgResize

    faces.lib(image.obj) : error LNK2019: unresolved external symbol __imp__ilGetError@0 referenced in function _frutilEvalILErrors

    Debug/facecmp.exe : fatal error LNK1120: 16 unresolved externals

    Build log was saved at "file://c:\temp\project\vcprj\cli\facecmp\Debug\BuildLog.htm"

    facecmp - 17 error(s), 0 warning(s)



    ---------------------- Done ----------------------

    Rebuild All: 1 succeeded, 1 failed, 0 skipped



    Thursday, July 03, 2008 8:03 AM

Answers


  • >>I am very sure that i have link them at the VC++ directories.
    >>If not my #include will have problem too isnt it?

    No.

    >>I have open up the IL.h file and all the "ilDeleteImages, ilSaveImage..etc" are all inside.
    >>So i am very confuse why is the error being prompt.

    Your errors are *linking* errors, which have nothing to do with the
    header files in the #include statements. If the header files were not
    getting picked up you would get *compile* errors.

    The linking errors are happening because the linker can't find the functions
    referenced in your program. This typically happens because either the lib
    file is not being found by the linker, or there is a conflict between C and C++
    naming. Was the lib built as C or C++? Is your program C or C++?

    - Wayne



    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:19 AM
    Friday, July 04, 2008 2:10 AM
  • >>The lib is in C language and as well as our program.

    But is your program being compiled as C++?

    If the file extension is .cpp then the default action is to compile it as C++
    which will cause the names to be "mangled" and the linker won't find them
    in the lib. If the extension is .c the default action is to compile it as C, but
    if the compiler option is set to *always* compile as C++ then again the
    names will get mangled/decorated. This can be prevented if the header uses,
    or is wrapped by, extern "C".

    - Wayne


    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:20 AM
    Friday, July 04, 2008 2:41 AM

  • >>may I know how do I find the compiler option to set the option?

    By looking for it in the compiler options. ;-)

    Where that is depends on which compiler and version you're using.
    Also it depends on whether you are compiling from the IDE or from the
    command line.

    >>how do I ensure that the header uses or is wrapped by, extern "C"?
    >>(Where should I put the declaration for the extern C?)

    In your program:

    #ifdef __cplusplus
    extern "C" {
    #endif
    #include "il.h" // or whatever its name
    #ifdef  __cplusplus
    }
    #endif

    - Wayne

    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:20 AM
    Friday, July 04, 2008 3:24 AM

  • >>it got other error
    >>error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup

    That error is unrelated to the previous errors or to the changes I suggested.

    Do you know the difference between a Windows Console mode program and
    a Windows GUI program? Between main() and WinMain()?

    The error message is telling you what the current problem is with your program.
    Your choice of main() or WinMain() does not match the build options you have
    chosen for Console or GUI (Windows). Make up your mind which kind of program
    you want to build and choose consistent code and options.

    >>I am using VS2003. I still cannot find the compiler option.

    Keep looking. Since I don't have VS2003 installed I won't waste my time (and yours)
    telling you where it is in VS2008. Note that the extern "C" appears to have eliminated
    the link errors you were getting from the 3rd party lib, so you may not need to concern
    yourself with the option at this time.

    - Wayne



    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:20 AM
    Friday, July 04, 2008 7:19 PM

All replies

  • Hi,

    Have you provided the implementation details of all the functions you are using ?

    Are you using any third party libraried ? If yes, then specify them in the project settings.

    Hope this will solve your problem.

    Regards,
    Paresh
    Thursday, July 03, 2008 10:08 AM
  • link against whatever import library provides those functions.

    By the looks of it, you're using DevIL image library. Check what libs it provides.
    Thursday, July 03, 2008 10:20 AM
  •  Hi all,

    Yup, i am using DevIL. I am very sure that i have link them at the VC++ directories. If not my #include will have problem too isnt it?
    I have open up the IL.h file and all the "ilDeleteImages, ilSaveImage..etc" are all inside. So i am very confuse why is the error being prompt. Please advise. Thanks
    Friday, July 04, 2008 1:07 AM
  • You need to find what *.lib files DevIL provides, and link then in your Project settings -> Linker -> Additional dependencies box.
    Friday, July 04, 2008 1:18 AM
  • i have tried your method. the problems are still there. Is it possible if it is some other problem?

    Friday, July 04, 2008 1:38 AM

  • >>I am very sure that i have link them at the VC++ directories.
    >>If not my #include will have problem too isnt it?

    No.

    >>I have open up the IL.h file and all the "ilDeleteImages, ilSaveImage..etc" are all inside.
    >>So i am very confuse why is the error being prompt.

    Your errors are *linking* errors, which have nothing to do with the
    header files in the #include statements. If the header files were not
    getting picked up you would get *compile* errors.

    The linking errors are happening because the linker can't find the functions
    referenced in your program. This typically happens because either the lib
    file is not being found by the linker, or there is a conflict between C and C++
    naming. Was the lib built as C or C++? Is your program C or C++?

    - Wayne



    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:19 AM
    Friday, July 04, 2008 2:10 AM
  • The lib is in C language and as well as our program.
    Friday, July 04, 2008 2:26 AM
  • >>The lib is in C language and as well as our program.

    But is your program being compiled as C++?

    If the file extension is .cpp then the default action is to compile it as C++
    which will cause the names to be "mangled" and the linker won't find them
    in the lib. If the extension is .c the default action is to compile it as C, but
    if the compiler option is set to *always* compile as C++ then again the
    names will get mangled/decorated. This can be prevented if the header uses,
    or is wrapped by, extern "C".

    - Wayne


    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:20 AM
    Friday, July 04, 2008 2:41 AM
  • Sorry for troubling you again. But may I know how do I find the compiler option to set the option?
    Or how do I ensure that the header uses or is wrapped by, extern "C"? (Where should I put the declaration for the extern C?)

    Thanks for your help!
    Friday, July 04, 2008 3:03 AM

  • >>may I know how do I find the compiler option to set the option?

    By looking for it in the compiler options. ;-)

    Where that is depends on which compiler and version you're using.
    Also it depends on whether you are compiling from the IDE or from the
    command line.

    >>how do I ensure that the header uses or is wrapped by, extern "C"?
    >>(Where should I put the declaration for the extern C?)

    In your program:

    #ifdef __cplusplus
    extern "C" {
    #endif
    #include "il.h" // or whatever its name
    #ifdef  __cplusplus
    }
    #endif

    - Wayne

    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:20 AM
    Friday, July 04, 2008 3:24 AM
  • i added the following into my prog already.

    #ifdef __cplusplus
    extern "C" {
    #endif
    #include "il.h" // or whatever its name
    #ifdef  __cplusplus
    }
    #endif

    But it got other error 

    MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup

    Debug/facecmp.exe : fatal error LNK1120: 1 unresolved externals


    I am using VS2003. I still cannot find the compiler option.

    Friday, July 04, 2008 4:34 AM

  • >>it got other error
    >>error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup

    That error is unrelated to the previous errors or to the changes I suggested.

    Do you know the difference between a Windows Console mode program and
    a Windows GUI program? Between main() and WinMain()?

    The error message is telling you what the current problem is with your program.
    Your choice of main() or WinMain() does not match the build options you have
    chosen for Console or GUI (Windows). Make up your mind which kind of program
    you want to build and choose consistent code and options.

    >>I am using VS2003. I still cannot find the compiler option.

    Keep looking. Since I don't have VS2003 installed I won't waste my time (and yours)
    telling you where it is in VS2008. Note that the extern "C" appears to have eliminated
    the link errors you were getting from the 3rd party lib, so you may not need to concern
    yourself with the option at this time.

    - Wayne



    • Marked as answer by Yan-Fei Wei Tuesday, July 08, 2008 2:20 AM
    Friday, July 04, 2008 7:19 PM
  • To ignore with the build option? After adding the extern "C" there will be another error which is 

    MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup

    Debug/facecmp.exe : fatal error LNK1120: 1 unresolved externals


    I did tried my best in debugging here and there finding those stuff, but after an error, smth ought to appear again

    Monday, July 07, 2008 8:58 AM
  • See my reply in the other thread you started on this same issue.

    - Wayne
    Monday, July 07, 2008 12:58 PM