
please wait
_declspec(dllimport)
. Without a .LIB file, you need to link at runtime using LoadLibrary()/GetProcAddress() as mentioned above.
|
|
|
|
Can you please post all the relevant code? |
std::string
|
|
|
|
1>------ Build started: Project: DLLTutorial, Configuration: Debug Win32 ------ 1>Build started 9/09/2012 8:03:49 PM. 1>InitializeBuildStatus: 1> Touching "Debug\DLLTutorial.unsuccessfulbuild". 1>ClCompile: 1> MyAdd.cpp 1>...\desktop\dlltutorial\dlltutorial\myadd.h(6): error C2059: syntax error : 'string' 1>...\desktop\dlltutorial\dlltutorial\myadd.h(6): error C2238: unexpected token(s) preceding ';' 1>...\desktop\dlltutorial\dlltutorial\myadd.cpp(3): error C2039: 'add' : is not a member of 'MyAdd' 1>...\desktop\dlltutorial\dlltutorial\myadd.h(4) : see declaration of 'MyAdd' 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:00.21 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
extern "C" |
1>------ Build started: Project: DLLTutorial, Configuration: Debug Win32 ------ 1>Build started 9/09/2012 8:09:04 PM. 1>InitializeBuildStatus: 1> Creating "Debug\DLLTutorial.unsuccessfulbuild" because "AlwaysCreate" was specified. 1>ClCompile: 1> MyAdd.cpp 1>Link: 1>...\Desktop\DLLTutorial\Debug\DLLTutorial.lib and object ...\Desktop\DLLTutorial\Debug\DLLTutorial.exp 1>LinkEmbedManifest: 1>...\Desktop\DLLTutorial\Debug\DLLTutorial.lib and object ...\Desktop\DLLTutorial\Debug\DLLTutorial.exp 1>...\Desktop\DLLTutorial\Debug\DLLTutorial.dll 1>FinalizeBuildStatus: 1> Deleting file "Debug\DLLTutorial.unsuccessfulbuild". 1> Touching "Debug\DLLTutorial.lastbuildstate". 1> 1>Build succeeded. 1> 1>Time Elapsed 00:00:00.69 ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== |
Where is the usage of string in that code? the error message points to line 7 of myadd.h, but you've only shown us 6 lines.. and the syntax error is not among them. Are you forgetting the namespace declaration in the offending line? std::string |
extern "C"
will not function at class scope. Do you really need C linkage? name mangling isn't an issue if you link implicitly. There are some workarounds.. but the code can get messy, and has it's own caveats:-http://eli.thegreenplace.net/2011/09/16/exporting-c-classes-from-a-dll/ |
http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL |
http://www.codeguru.com/cpp/w-p/dll/importexportissues/article.php/c123/Explicitly-Linking-to-Classes-in-DLLs.htm |
|
|