| | |
@@Creating DLL in @@
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
Hi,
I am using dev c++ 4.9.9.2 and I am new to DLLs. I am tryig to create a DLL which I am not creating thru the "DLL project" in dev cpp.
Here are my three files:
//dlltest.h
//dlltest.cpp
//hello.cpp
I now compile dlltest.cpp by:
g++ -c dlltest.cpp -DBUILD_DLL
I get errors related to the EXPORT keyword in "dlltest.h"
What corrections are required in the 3 files (if any)
And how do I create DLLs ? (are there any compiler options/switches I need to modify/correct?)
I am using dev c++ 4.9.9.2 and I am new to DLLs. I am tryig to create a DLL which I am not creating thru the "DLL project" in dev cpp.
Here are my three files:
//dlltest.h
C++ Syntax (Toggle Plain Text)
#ifndef _DLLTEST_H #define _DLLTEST_H #ifdef BUILD_DLL #define EXPORT _declspec(dllexport) #else #define EXPORT _declspec(dllimport) #endif EXPORT void Hello(); #endif //end of _DLLTEST_H
//dlltest.cpp
C++ Syntax (Toggle Plain Text)
#include "dlltest.h" #include<iostream> using namespace std; EXPORT void Hello(){ cout<<"This is DLL test"; }
//hello.cpp
C++ Syntax (Toggle Plain Text)
#include "dlltest.h" int main(){ Hello(); }
I now compile dlltest.cpp by:
g++ -c dlltest.cpp -DBUILD_DLL
I get errors related to the EXPORT keyword in "dlltest.h"
What corrections are required in the 3 files (if any)
And how do I create DLLs ? (are there any compiler options/switches I need to modify/correct?)
PEACE !
You've compiled the code, but you still haven't linked it into DLL and lib files.
Make them with
This creates both the DLL and an import library. If all you want is the DLL, ignore the stuff that isn't in red. (That's a -W and lower-case L.)
See this link for more.
Good luck.
Make them with
g++ -shared -o dlltest.dll dlltest.o -Wl,--out-implib,libdlltest.aThis creates both the DLL and an import library. If all you want is the DLL, ignore the stuff that isn't in red. (That's a -W and lower-case L.)
See this link for more.
Good luck.
Hi there and thanks for the reply,
I will check whatever you have told me to...However there's another thing that i must tell you..
I tried using a DLL project this time which gave me some skeletons (i.e. two files one .h and other .main)
I included a third file in my project(which is part of the project), say hello.cpp
It compiles fine. But when I run the prj(or the hello.cpp file)..It gives me an error saying ..
warning :No host application found. You can specify in the paratmeters,execute menu.
I dont exactly understand the meaning of the message.I mean I did go to the parameters option in the execute menu (I think) and all i found was a parameters field and another field which cud open files of type ".exe" only!
After compilation it creates the DLL as projectname.dll
I created another cpp file (outside the project) and tried calling the function from my DLL project like this:
It gives me errors...
cud you help???
I will check whatever you have told me to...However there's another thing that i must tell you..
I tried using a DLL project this time which gave me some skeletons (i.e. two files one .h and other .main)
I included a third file in my project(which is part of the project), say hello.cpp
It compiles fine. But when I run the prj(or the hello.cpp file)..It gives me an error saying ..
warning :No host application found. You can specify in the paratmeters,execute menu.
I dont exactly understand the meaning of the message.I mean I did go to the parameters option in the execute menu (I think) and all i found was a parameters field and another field which cud open files of type ".exe" only!
After compilation it creates the DLL as projectname.dll
I created another cpp file (outside the project) and tried calling the function from my DLL project like this:
C++ Syntax (Toggle Plain Text)
myfile.cpp: #include "dll.h" . . DLLIMPORT void hello(void); int main(){ hello(); return 0; }
cud you help???
PEACE !
When you are using an IDE, the options are usually (as they are in your case) to create either a DLL or an EXE. You can't create both in the same project.
Start a DLL project to make your DLL. Make the DLL.
Then start an normal application project. #include the .h from the DLL project. Make and run the EXE.
A DLL is not designed to be executed like an EXE --the entry point (if any) is different and different operating constraints apply. I think you need to read up a little more on the difference between a DLL and an EXE.
Hope this helps.
Start a DLL project to make your DLL. Make the DLL.
Then start an normal application project. #include the .h from the DLL project. Make and run the EXE.
A DLL is not designed to be executed like an EXE --the entry point (if any) is different and different operating constraints apply. I think you need to read up a little more on the difference between a DLL and an EXE.
Hope this helps.
![]() |
Similar Threads
- Creating a VB dll (Visual Basic 4 / 5 / 6)
- creating and using dll (Visual Basic 4 / 5 / 6)
- Linking errors while creating dll using ATL project (C++)
- Dll from C++ to C# (C++)
- Need a VB DLL to call from BCBuilder++ (VB.NET)
- Doubt regarding creating “*.dll� file by visual studio 6.0. (C++)
Other Threads in the C++ Forum
- Previous Thread: Including external files in the program
- Next Thread: Converting the array into string
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream input int integer java lib linux list loop looping loops map math matrix memory multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






