shared dll

hi
i have created .dll and .o file of my huffman class like this :
g++ -c huffman.cpp
g++ -shared -o huffman.dll huffman.o
and i have also huffman.h proto file.
now i want to know is there any way to use these files in vc++2008 whithout loadlibrary and getprocaddress function?
or i need .lib file? if yes how can i create it?

closed account (zb0S216C)
Just link the .lib and make sure the .dll is within the same directory as the executable. From there, include the header(s) pertaining to the DLL and call any functions from the header; your linker will look in your library for the function's definition.

Note that if your compiler is set to compile for multiple platforms, you'll get multiple extensions.

I've been creating DLLs for a while, and I never:

1) ...used dllexport/dllimport
2) ...used WIndows' API to link a DLL

Wazzak
Last edited on
hi
i made .a file using rv and did what you said and got this :

------ Build started: Project: aaa, Configuration: Debug Win32 ------
Linking...
aaa.obj : error LNK2028: unresolved token (0A000302) "public: void __thiscall huffman::encode(void)" (?encode@huffman@@$$FQAEXXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
aaa.obj : error LNK2028: unresolved token (0A000303) "public: __thiscall huffman::huffman(char const *,char const *)" (??0huffman@@$$FQAE@PBD0@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
aaa.obj : error LNK2019: unresolved external symbol "public: void __thiscall huffman::encode(void)" (?encode@huffman@@$$FQAEXXZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
aaa.obj : error LNK2019: unresolved external symbol "public: __thiscall huffman::huffman(char const *,char const *)" (??0huffman@@$$FQAE@PBD0@Z) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
C:\Documents and Settings\sourena\My Documents\Visual Studio 2008\Projects\aaa\Debug\aaa.exe : fatal error LNK1120: 4 unresolved externals
Build log was saved at "file://c:\Documents and Settings\sourena\My Documents\Visual Studio 2008\Projects\aaa\aaa\Debug\BuildLog.htm"
aaa - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


i have written my code using standard cpp and it works fine in ubuntu and windows(mingw)
but i dont know why it works diffrent in vc++
closed account (zb0S216C)
It seems as though you've created a CLI/C++ project, not a C++ one. You need to change that. Also, if you've chose a DLL project, and not a shard library project, you'll have to export the functions with __declspec(dllexport) (this should reside between the function return type-specifier and the identifier (same with the class/struct)).

Wazzak
i m trying to use MFC aplication to make gui for "huffman class" i ve written in c++ in ubuntu.

http://www.cplusplus.com/forum/general/59923/
Last edited on
Topic archived. No new replies allowed.