CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2005
    Location
    Detroit MI
    Posts
    80

    Problem with DLL / Lib

    Hi There,

    I'm using a 3rd party lib file and headers in a project of mine.

    Once I start using the functionality provided by the .lib file I started getting the following error when compiling :

    Code:
    LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    After doing some research, it seemed I had to add it to the 'ignore specific library' list in the VC++ 2005 project settings under -> Project Properties-> Linker -> Input ->Ignore Specific Library. Fine - did that! (added msvcrt.lib to the list).

    Built and cleaned the soultion and all seemed OK. No errors or warning.

    Now, when I run the application, code is below,(which is just a console project that simply creates an instance of structure contained within the library and then calls a function, also within the .lib file to clear it (by passing its address)) I receive the following in the Debug window, and the program appears "trapped":

    Code:
    'eval-test.exe': Loaded 'D:\Projects\eval-test\debug\eval-test.exe', Symbols loaded.
    'eval-test.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
    'eval-test.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
    'eval-test.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll', Symbols loaded.
    eval-test.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
    First-chance exception at 0x102308cf (msvcr80d.dll) in eval-test.exe: 0xC0000005: Access violation writing location 0x00130000.
    First-chance exception at 0x00000000 in reval-test.exe: 0xC0000005: Access violation reading location 0x00000000.
    First-chance exception at 0x00000000 in eval-test.exe: 0xC0000005: Access violation reading location 0x00000000.
    First-chance exception at 0x00000000 in eval-test.exe: 0xC0000005: Access violation reading location 0x00000000.
    First-chance exception at 0x00000000 in eval-test.exe: 0xC0000005: Access violation reading location 0x00000000.
    First-chance exception at 0x00000000 in eval-test.exe: 0xC0000005: Access violation reading location 0x00000000.
    The thread 'Win32 Thread' (0x8d8) has exited with code -1073741510 (0xc000013a).
    The program '[2984] eval-test.exe: Native' has exited with code -1073741510 (0xc000013a).
    Here's the code in it's entirety:
    Code:
    int _tmain(int argc, _TCHAR* argv[])
    {
    	enum_result_t resulta;
    	enumResultClear(&resulta);
    	return 0;
    }
    Regards,

    Big Winston

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Problem with DLL / Lib

    It doesn't do any good posting those three lines. They are all valid C++ syntax.

    No one knows what enumResultsClear() does. You are telling us second-hand what it does, but how can we know this for sure? The errors are clear in that the function caused an access violation.

    Maybe the structure needs to be initialized somehow by you before you send it to the enumResultsClear()? I don't know, you should tell us *exactly* what the documentation says what the function is supposed to do, and if any prerequisites are required before calling it.

    It could also be a bug in the library itself. Again, three lines of code with no context isn't going to help solve the problem.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Mar 2005
    Location
    Detroit MI
    Posts
    80

    Re: Problem with DLL / Lib

    Ok, I didn't think it was a problem with the code, I had assumed that it was a problem with my project settings.

    There is no documentation for the library, but I do have the source code for the function. Here it is:

    Code:
    void enumResultClear(enum_result_t *result)
    {
      memset(result, 0, sizeof(enum_result_t));
    }
    the structure 'result' is as follows:

    Code:
    typedef struct {
      enum_game_t game;
      enum_sample_t sampleType;
      unsigned int nsamples;
      unsigned int nplayers;
      unsigned int nwinhi[ENUM_MAXPLAYERS];
      unsigned int ntiehi[ENUM_MAXPLAYERS];
      unsigned int nlosehi[ENUM_MAXPLAYERS];
      unsigned int nwinlo[ENUM_MAXPLAYERS];
      unsigned int ntielo[ENUM_MAXPLAYERS];
      unsigned int nloselo[ENUM_MAXPLAYERS];
      unsigned int nscoop[ENUM_MAXPLAYERS]; 
      unsigned int nsharehi[ENUM_MAXPLAYERS][ENUM_MAXPLAYERS+1];
      unsigned int nsharelo[ENUM_MAXPLAYERS][ENUM_MAXPLAYERS+1];
      unsigned int nshare[ENUM_MAXPLAYERS][ENUM_MAXPLAYERS+1][ENUM_MAXPLAYERS+1];
      double ev[ENUM_MAXPLAYERS];
      enum_ordering_t *ordering;
    } enum_result_t;
    Regards,

    Big Winston

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Problem with DLL / Lib

    Are you sure the DLL and your source code are built using the same settings, in terms of structure alignment?

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    Mar 2005
    Location
    Detroit MI
    Posts
    80

    Re: Problem with DLL / Lib

    No I'm not. I'm new to using DLL's.

    I can tell you I build the DLL / Lib using the nmake tool and a makefile.dos

    Here's the copy of the makefile if its any use :

    Code:
    # Generated automatically from Makefile.in by configure.
    LIBPOKER = ../lib/libpoker.lib
    
    CC = cl 
    CFLAGS = -O1 -nologo -DNDEBUG -MD -DMSDOS 
    RANLIB = rem 
    AR = ar
    RM = del
    CC_OBJ = $(CC) $(CFLAGS) -I../include -c -Fo$@ $**
    CC_EXE = $(CC) $(CFLAGS) -I../include -Fe$@ $**
    RUN_IT = $**
    LIB_CMD = LIB /OUT:$@ $**
    
    PROGRAMS = five_card_hands.exe seven_card_hands.exe fish.exe eval.exe \
    	hcmp2.exe hcmpn.exe usedecks.exe pokenum.exe
    
    all : $(PROGRAMS)
    
    five_card_hands.exe: five_card_hands.obj $(LIBPOKER)
    	$(CC_EXE)
    
    seven_card_hands.exe: seven_card_hands.obj $(LIBPOKER)
    	$(CC_EXE)
    
    fish.exe: fish.obj $(LIBPOKER)
    	$(CC_EXE)
    
    eval.exe: eval.obj $(LIBPOKER)
    	$(CC_EXE)
    
    hcmp2.exe: hcmp2.obj $(LIBPOKER)
    	$(CC_EXE)
    
    hcmpn.exe: hcmpn.obj $(LIBPOKER)
    	$(CC_EXE)
    
    usedecks.exe: usedecks.obj $(LIBPOKER)
    	$(CC_EXE)
    
    pokenum.exe: pokenum.obj $(LIBPOKER)
    	$(CC_EXE)
    
    clean:
    	$(RM) core *.obj $(PROGRAMS) 
    
    .c.obj:
    	$(CC_OBJ)
    
    Makefile: Makefile.in
    Regards,

    Big Winston

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Problem with DLL / Lib

    Quote Originally Posted by BigWinston
    No I'm not. I'm new to using DLL's.
    Basically, what is sizeof(enum_result_t) in your app, and what is sizeof(enum_result_t) in your DLL? Are they the same?

    You will need to add this to your code to determine what they are.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured