Thread: VC++ a POS

  1. #16
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Quote Originally Posted by abachler View Post
    link errors are always caused by failure to include the appropriate library. In this case you arent linking against LIBC.LIB or LIBCMT.LIB
    LINK : fatal error LNK1104: cannot open file 'LIBC.LIB'

    If I add libcmt.lib I get these errors:

    Linking...
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _free already defined in libcmt.lib(free.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strncmp already defined in libcmt.lib(strncmp.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strrchr already defined in libcmt.lib(strrchr.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _realloc already defined in libcmt.lib(realloc.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strtol already defined in libcmt.lib(strtol.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strtoul already defined in libcmt.lib(strtol.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _tolower already defined in libcmt.lib(tolower.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _strchr already defined in libcmt.lib(strchr.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _isspace already defined in libcmt.lib(_ctype.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _abort already defined in libcmt.lib(abort.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _exit already defined in libcmt.lib(crt0dat.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __errno already defined in libcmt.lib(dosmap.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _isdigit already defined in libcmt.lib(_ctype.obj)
    MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: _calloc already defined in libcmt.lib(calloc.obj)
    MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in libcmt.lib(typinfo.obj)
    MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info:perator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in libcmt.lib(typinfo.obj)
    LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
    xform.obj : error LNK2019: unresolved external symbol _pclose referenced in function _pipe_color_transformer
    xform.obj : error LNK2019: unresolved external symbol _popen referenced in function _pipe_color_transformer
    GIFAnimator.obj : error LNK2019: unresolved external symbol "int __cdecl gifmain(int,char * *)" (?gifmain@@YAHHPAPAD@Z) referenced in function "void __cdecl OptimizeGif(struct HWND__ *)" (?OptimizeGif@@YAXPAUHWND__@@@Z)
    Debug\blah.exe : fatal error LNK1120: 3 unresolved externals

  2. #17
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Now what? It must be my sloppy code then huh? So every opensource project I download off the net is sloppy? Jeez, nobody knows who to write clean code these days I guess...

  3. #18
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by Welder View Post
    I have these libraries included
    kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
    Originally Posted by abachler http://cboard.cprogramming.com/image...s/viewpost.gif
    link errors are always caused by failure to include the appropriate library. In this case you arent linking against LIBC.LIB or LIBCMT.LIB


    Enough said.

  4. #19
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Quote Originally Posted by abachler View Post
    [/I]

    Enough said.
    So what do I need to include to fix this?

    And how will an external library make the linker not be able to link my own functions properly?

  5. #20
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    'Your' functions most likely use functions contained in the C runtime library, something Bloodshed links behind the scenes. Because VC++ is far more flexible, it requires you to link the library explicitly, either by creating a windows project, or by manually entering the LIB in the link list. VC++ compiles a lot more than just windows programs. You may also be using the wrong template when creating your project. The fact that this file isnt linked by default makes me strongly suspect that is the case. If you are compiling MFC code you have to make an MFC project, as MFC and standard C/C++ are not compatible. If you are making a standard windows program, then you need to make a 'Win32' project. If you are compiling console appliation then you need to make a Win32 Console Application'. It also looks like you are linking everything, which means a lot of things are going to conflict. You cant link both LIBC.LIB LIBCMT.LIB and LIBCRTD>LIB as they all contain the same functions, just in different ways. First, you need to scrap the projects you have and make a new one, then add the SOURCE CODE files to your project one at a time. The problem isnt with VC++, its with bloodshed doing too much for you, and now you dont know how to set up a project properly.
    Last edited by abachler; 11-06-2007 at 03:43 PM.

  6. #21
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    I had a lot of problems at first, but there's a platform SDK that I downloaded and it fixed everything (namely it not having <windows.h> in its include). I can't remember what it was, but I'm sure you can find it. Also, Visual C++ 2008 Express is out, you should try that one.

  7. #22
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    I tried making a new win32 project file, started fresh and got this error:

    cl : Command line error D8045 : cannot compile C file '..\..\src\funopt.c' with the /clr option

    So I turned off the /clr option and I get all those link errors with popen pclose again.

  8. #23
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Alright, I fixed that part. Ends up VC++ doesn't like .c files.

  9. #24
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Now an error I am getting when compiling some gif code I downloaded is the following:

    gifwrite.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (Gif_Context): (0x02000005).
    LINK : fatal error LNK1255: link failed because of metadata errors


    Code:
    typedef struct {
      
      Gif_Stream *stream;
      
      Gif_Code *prefix;
      uint8_t *suffix;
      uint16_t *length;
      
      uint16_t width;
      uint16_t height;
      
      uint8_t *image;
      uint8_t *maximage;
      
      unsigned decodepos;
    
      Gif_ReadErrorHandler handler;
      void *handler_thunk;
      
    } Gif_Context;
    
    
    And in another source file I have this
    
    typedef struct Gif_Context {
      
      Gif_Node *nodes;
      int nodes_pos;
      Gif_Node **links;
      int links_pos;
      
    } Gif_Context;
    I think I see the problem. I will try something and get back to you guys.
    Last edited by Welder; 11-06-2007 at 04:35 PM.

  10. #25
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Welder View Post
    Now an error I am getting when compiling some gif code I downloaded is the following:

    gifwrite.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (Gif_Context): (0x02000005).
    LINK : fatal error LNK1255: link failed because of metadata errors


    Code:
    typedef struct {
      
      Gif_Stream *stream;
      
      Gif_Code *prefix;
      uint8_t *suffix;
      uint16_t *length;
      
      uint16_t width;
      uint16_t height;
      
      uint8_t *image;
      uint8_t *maximage;
      
      unsigned decodepos;
    
      Gif_ReadErrorHandler handler;
      void *handler_thunk;
      
    } Gif_Context;
    
    
    And in another source file I have this
    
    typedef struct Gif_Context {
      
      Gif_Node *nodes;
      int nodes_pos;
      Gif_Node **links;
      int links_pos;
      
    } Gif_Context;
    I think I see the problem. I will try something and get back to you guys.
    That is really bad style - don't EVER use the same name or completely different structures.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #26
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Finally compiled. But there are issues with it now. Oh well...

    :shrug:

    Problem I am having is all my string code is not working.

    SetDlgItemText(hwnd, IDC_BATCH_PATH, "C:\\");

    Enters some random characters. Msgboxes, dialog boxes, and any control that my code "sets" the text for gets garbled.

    [edit] Oh wait...unicode. hold on, brb
    Last edited by Welder; 11-06-2007 at 04:45 PM.

  12. #27
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Quote Originally Posted by matsp View Post
    That is really bad style - don't EVER use the same name or completely different structures.

    --
    Mats
    Not my code.

  13. #28
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Welder View Post
    Not my code.
    Sure, but I don't really think we can blame the compiler for moaning [although I would also argue that it's perfectly valid to HAVE that sort of construction - although bad style].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #29
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    WOOHOO!!!!

    It worked!! Hell ya, thanks for your help guys.

    Only took 10 hours of hell to get it figured out. I still hate the program, but will probably end up using it because of it's support.

  15. #30
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by CornedBee View Post
    MFC is not supplied with the Express version. If the file was generated by a resource editor and you don't actually use MFC, change the include to windows.h.
    Actually, the psdk has a copy of afxres.h in /Include/mfc so you just need to add that path to the include paths for msvc, if you want.
    Quote Originally Posted by Welder
    nor is #include <afxres.h>
    The dummy 'afxres.h' header was originally created for MinGW(the 'compiler' used by Dev-Cpp) to provide compatibility with msvc resources; that MinGW header just #includes <windows.h> and #defines IDC_STATIC so you'd just need to duplicate these, as CornedBee has already mostly suggested, if you'd rather not set the path as previously mentioned.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. file i/o dilemma
    By adramalech in forum C Programming
    Replies: 27
    Last Post: 11-11-2008, 12:30 AM
  2. seperate and add pos and neg numbers
    By Chris630 in forum C++ Programming
    Replies: 2
    Last Post: 03-27-2007, 06:14 PM
  3. makefile exported by vc 6.0 doesn't work
    By wow in forum Windows Programming
    Replies: 7
    Last Post: 03-24-2006, 04:20 PM
  4. Debug help needed
    By Achy in forum C Programming
    Replies: 3
    Last Post: 11-16-2005, 03:27 PM
  5. determine if input pos or neg ?
    By bluenoser in forum C Programming
    Replies: 2
    Last Post: 10-20-2002, 08:49 PM