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. Problem with extern and linkage

Problem with extern and linkage

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 Posts 2 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.
  • J Offline
    J Offline
    Janine
    wrote on last edited by
    #1

    Hi, I'm using a library and I need to redirect function calls in that library. What I mean is that in the library, there are calls to a function and I want the calls to be calls of another function. The problem is that I can't include that file, where those new functions are to the library and I can't modify that library very much. So, I'm using extern and define in the files of the library to solve the problem and I'm able to make the library without compilation/linking errors. The problem is how to link/compile/include the library with my application? Now I keep getting LNK2001 errors telling me that the library doesn't find the definitions of those functions. I'm using makefile and in there I have linked the object file that contains the new functions to be used and also the library. That is apparently not enough. I even tried putting the object file before the library when linking. -Janetta

    J 1 Reply Last reply
    0
    • J Janine

      Hi, I'm using a library and I need to redirect function calls in that library. What I mean is that in the library, there are calls to a function and I want the calls to be calls of another function. The problem is that I can't include that file, where those new functions are to the library and I can't modify that library very much. So, I'm using extern and define in the files of the library to solve the problem and I'm able to make the library without compilation/linking errors. The problem is how to link/compile/include the library with my application? Now I keep getting LNK2001 errors telling me that the library doesn't find the definitions of those functions. I'm using makefile and in there I have linked the object file that contains the new functions to be used and also the library. That is apparently not enough. I even tried putting the object file before the library when linking. -Janetta

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Maybe you're misxing C and C++ styles of linking. Make sure the portion of library using the external function and the object code providing it are the same language. You can also use extern "C" in both parts if the languages are different. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      J 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        Maybe you're misxing C and C++ styles of linking. Make sure the portion of library using the external function and the object code providing it are the same language. You can also use extern "C" in both parts if the languages are different. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        J Offline
        J Offline
        Janine
        wrote on last edited by
        #3

        But of course that was the problem:) Thanks! -Janetta

        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