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