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. Use of functions from DLL using extern [modified]

Use of functions from DLL using extern [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpvisual-studiohelpquestion
4 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.
  • Y Offline
    Y Offline
    ytubis
    wrote on last edited by
    #1

    Hi! I have build a TCP DLL, and now I want to use it. I have created all the typedefs for the function inside the DLL and now I want to use them with extern. I added the DLL to my linker as an input but I get errors: This is the code: extern TCPLIB_RETRIEVE_N_BYTES_PTR tcplib_retrieve_n_bytes_ptr; These are the errors: Error 1 error C2146: syntax error : missing ';' before identifier 'tcplib_retrieve_n_bytes_ptr' d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest What am I doing wrong here? Is there another place to define the DLL in my project? Thanks guys :) :)

    modified on Saturday, April 18, 2009 12:56 PM

    S 1 Reply Last reply
    0
    • Y ytubis

      Hi! I have build a TCP DLL, and now I want to use it. I have created all the typedefs for the function inside the DLL and now I want to use them with extern. I added the DLL to my linker as an input but I get errors: This is the code: extern TCPLIB_RETRIEVE_N_BYTES_PTR tcplib_retrieve_n_bytes_ptr; These are the errors: Error 1 error C2146: syntax error : missing ';' before identifier 'tcplib_retrieve_n_bytes_ptr' d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest What am I doing wrong here? Is there another place to define the DLL in my project? Thanks guys :) :)

      modified on Saturday, April 18, 2009 12:56 PM

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      ytubis wrote:

      Error 1 error C2146: syntax error : missing ';' before identifier 'tcplib_retrieve_n_bytes_ptr' d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest
      Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest

      That means that the compiler can't see the defintion of TCPLIB_RETRIEVE_N_BYTES_PTR - you need a definition of the type for the compiler to see. DLL's can't export type definitions, only functions and variables (and don't think that DLLs export classes as types - they don't, they export the class's methods).

      ytubis wrote:

      I added the DLL to my linker as an input but I get errors:

      You need to add the import library to the linker input, NOT the DLL.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      Y 1 Reply Last reply
      0
      • S Stuart Dootson

        ytubis wrote:

        Error 1 error C2146: syntax error : missing ';' before identifier 'tcplib_retrieve_n_bytes_ptr' d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest
        Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest

        That means that the compiler can't see the defintion of TCPLIB_RETRIEVE_N_BYTES_PTR - you need a definition of the type for the compiler to see. DLL's can't export type definitions, only functions and variables (and don't think that DLLs export classes as types - they don't, they export the class's methods).

        ytubis wrote:

        I added the DLL to my linker as an input but I get errors:

        You need to add the import library to the linker input, NOT the DLL.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        Y Offline
        Y Offline
        ytubis
        wrote on last edited by
        #3

        Thank you very much. But let me understand: I have created TCPlib.dll, this is the build for the library. I add this dll to the new project where I try to extern the function pointers. in the input linker I gave TCPlib.lib and another time TCPlib.dll and I get that the project can not find them: Error 1 fatal error LNK1104: cannot open file 'TCPlib.lib' ServerTest ServerTest I have the dll in the library of the project and also attached to the project as an Item. what am I doing wrong? Thanks for your help :)

        S 1 Reply Last reply
        0
        • Y ytubis

          Thank you very much. But let me understand: I have created TCPlib.dll, this is the build for the library. I add this dll to the new project where I try to extern the function pointers. in the input linker I gave TCPlib.lib and another time TCPlib.dll and I get that the project can not find them: Error 1 fatal error LNK1104: cannot open file 'TCPlib.lib' ServerTest ServerTest I have the dll in the library of the project and also attached to the project as an Item. what am I doing wrong? Thanks for your help :)

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          Unless the DLL project is in the same solution as the executable's project and you've added the DLL project as a dependency of the executable one, you also need to tell the linker what directory the library (that is, TCPlib.lib) is in.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          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