Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DLL works with C++, but linker error with C

DLL works with C++, but linker error with C

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++questionvisual-studiodebugging
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    normanS
    wrote on last edited by
    #1

    Hi - I read about InpOut32.dll (dll letting you access I/O ports in Nt / 2000 / XP) on some CodeProject article. The link for the DLL, with source code, is http://www.logix4u.net/inpout32.htm. I downloaded InpOut32 and copied the relevant lines from their sample CPP application to my "C" application, but I got linker errors as shown below: TestProg.obj : error LNK2001: unresolved external symbol _Inp32@4 TestProg.obj : error LNK2001: unresolved external symbol _Out32@8 Debug/TestProg.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. After hours of trying to find differences between my program and the sample program, someone suggested that "C" files and "CPP" files are handled differently. I changed the name of my main program file from TestProg.c to TestProg.cpp, and the project now compiles and runs fine. I made no other changes to the project (same libraries linked, etc.) Unfortunately, the change from C to CPP compilation affects other parts of the program, so I would like to change the main program back to "C". What are the differences between how Visual Studio 6 handles "C" files compared to how it handles "CPP" files? How do I get this DLL to work with my C application?

    N 1 Reply Last reply
    0
    • N normanS

      Hi - I read about InpOut32.dll (dll letting you access I/O ports in Nt / 2000 / XP) on some CodeProject article. The link for the DLL, with source code, is http://www.logix4u.net/inpout32.htm. I downloaded InpOut32 and copied the relevant lines from their sample CPP application to my "C" application, but I got linker errors as shown below: TestProg.obj : error LNK2001: unresolved external symbol _Inp32@4 TestProg.obj : error LNK2001: unresolved external symbol _Out32@8 Debug/TestProg.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe. After hours of trying to find differences between my program and the sample program, someone suggested that "C" files and "CPP" files are handled differently. I changed the name of my main program file from TestProg.c to TestProg.cpp, and the project now compiles and runs fine. I made no other changes to the project (same libraries linked, etc.) Unfortunately, the change from C to CPP compilation affects other parts of the program, so I would like to change the main program back to "C". What are the differences between how Visual Studio 6 handles "C" files compared to how it handles "CPP" files? How do I get this DLL to work with my C application?

      N Offline
      N Offline
      normanS
      wrote on last edited by
      #2

      OK, my next rule is "think before you post". At least I found the answer myself before anyone flamed me. I had a look at some Borland C++ samples which came with the InpOut32 DLL, and used the "traditional" DLL techniques used there - LoadLibrary, GetProcAddress, etc. My code now works fine as a C file.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups