#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    127
    Rep Power
    10

    PortTalk and Windows MFC Program


    I have been trying to use the PortTalk driver to interface with a parallel port.

    The code works OK via a console application (WIndows 2000), but when I try and build the code for a MFC application I get the following errors:-

    Code:
    ParallelPortTest error LNK2005: "void __cdecl outportb(unsigned short,unsigned char)" (?outportb@@YAXGE@Z) already defined in ParallelPortTest.obj
    ParallelPortTest error LNK2005: "unsigned char __cdecl inportb(unsigned short)" (?inportb@@YAEG@Z) already defined in ParallelPortTest.obj
    ParallelPortTest error LNK2005: "unsigned char __cdecl OpenPortTalk(void)" (?OpenPortTalk@@YAEXZ) already defined in ParallelPortTest.obj
    ParallelPortTest error LNK2005: "void __cdecl ClosePortTalk(void)" (?ClosePortTalk@@YAXXZ) already defined in ParallelPortTest.obj
    ParallelPortTest error LNK2005: "unsigned char __cdecl StartPortTalkDriver(void)" (?StartPortTalkDriver@@YAEXZ) already defined in ParallelPortTest.obj
    ParallelPortTest error LNK2005: "void __cdecl InstallPortTalkDriver(void)" (?InstallPortTalkDriver@@YAXXZ) already defined in ParallelPortTest.obj
    ParallelPortTest error LNK2005: "void * PortTalk_Handle" (?PortTalk_Handle@@3PAXA) already defined in ParallelPortTest.obj
    ParallelPortTest warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    ParallelPortTest fatal error LNK1169: one or more multiply defined symbols found
    Any suggests to overcome this problem with Visual Studio .Net
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    8
    Rep Power
    0
    Have you imported the library file into the project?
    And included the header file?
  4. #3
  5. Lord of Dorkness
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2004
    Location
    Central New York. Texan via Arizona, out of his element!
    Posts
    8,524
    Rep Power
    3269
    I don't believe it's a MISSING lib - it looks like the opposite; object code available in more than one library file. It appears you may need to use a different run-time library.
    Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
    If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it.
    DaWei on Pointers Politically Incorrect.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    127
    Rep Power
    10

    Missing Library


    I have not included any library's as apart from the PortTalk.sys files and .c and .h files none other present (or needed?)

    Andy.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    127
    Rep Power
    10

    Which One?


    Any more information as I am totally lost.

    You sometimes run into major problems when using MFC and other non-standard facilities.

    Andy.

    PS Should I just use the Console application and use events (fired by the MFC program) to get the Console application to do the port access - but that seems the long way round!
  10. #6
  11. Lord of Dorkness
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2004
    Location
    Central New York. Texan via Arizona, out of his element!
    Posts
    8,524
    Rep Power
    3269
    What you mean is you haven't OVERTLY included any libraries beyond blah blah blah. I can't drop a link to this (though I suspect you might find it on MSDN, as it comes from my local documentation.
    Linker Tools Warning LNK4098
    defaultlib "library" conflicts with use of other libs; use /NODEFAULTLIB:library

    You are trying to link with incompatible libraries.

    Important The run-time libraries now contain directives to prevent mixing different types. Youíll receive this warning if you try to use different types or debug and non-debug versions of the run-time library in the same program. For example, if you compiled one file to use one kind of run-time library and another file to use another kind (for example, single-threaded versus multithreaded) and tried to link them, youíll get this warning. You should compile all source files to use the same run-time library. See the Use Run-Time Library (MD, /ML, /MT, /LD) compiler options for more information.

    You can use the linkerís /VERBOSE:LIB switch to determine which libraries the linker is searching. If you receive LNK4098 and want to create an executable file that uses, for example, the single-threaded, non-debug run-time libraries, use the /VERBOSE:LIB option to find out which libraries the linker is searching. The linker should print LIBC.LIB and not LIBCMT.LIB, MSVCRT.LIB, LIBCD.LIB, LIBCMTD.LIB, or MSVCRTD.LIB as the libraries searched. You can tell the linker to ignore the the incorrect run-time libraries by typing the incorrect libraries in the Ignore Libraries text box on the Link tab of the Settings dialog box in Developerís Studio or by using the /NODEFAULTLIB:library option with LINK for each library you want to ignore. See the Ignore Libraries (/NODEFAULTLIB) linker option for more information.

    The table below shows which libraries should be ignored depending on which run-time library you want to use.

    To use this run-time library Ignore these libraries
    Single-threaded (libc.lib) libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
    Multithreaded (libcmt.lib) libc.lib, msvcrt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
    Multithreaded using DLL (msvcrt.lib) libc.lib, libcmt.lib, libcd.lib, libcmtd.lib, msvcrtd.lib
    Debug Single-threaded (libcd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcmtd.lib, msvcrtd.lib
    Debug Multithreaded (libcmtd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, msvcrtd.lib
    Debug Multithreaded using DLL (msvcrtd.lib) libc.lib, libcmt.lib, msvcrt.lib, libcd.lib, libcmtd.lib


    For example, if you received this warning and you want to create an executable file that uses the non-debug, single-threaded version of the run-time libraries, you could use the following options with the linker:

    /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib
    Sorry for the length, but I didn't feel like seaching MSDN for you at the moment.
    Functionality rules and clarity matters; if you can work a little elegance in there, you're stylin'.
    If you can't spell "u", "ur", and "ne1", why would I hire you? 300 baud modem? Forget I mentioned it.
    DaWei on Pointers Politically Incorrect.

IMN logo majestic logo threadwatch logo seochat tools logo