Hi,
I have sources of C + + that I will compile on Linux ultimately be used on windows (C #). Ouch! Ouch! Ouch!
So I tried some tests but in vain so far ...
My tux.h file (I am not the cpp that are irrelevant) Linux is:
I compile with mingw32 on linux:Code:1. # ifndef TUX_H 2. # define TUX_H 3. DLL_EXPORT # define __declspec (dllexport) 4. 5. extern "C" ( 6. class DLL_EXPORT Tux 7. ( 8. private: 9. const char * NAME; 10. public: 11. Tux (void) (NAME = "Racer";) 12. const char * __stdcall getName (); 13. ); 14. ) 15. # endif / / TUX_H
I turn on Windows ...Code:1. mingw32msvc-i586-g + +-Wall-shared-o tux.cc tux.dll-Wl, - output-def, tux.def
I created the lib:
I created my VSC + + project (CLR can later call my class from C #).Code:1. lib / def: tux.def
I enclose my tux.h I put tux.dll and tux.lib in the debug directory.
I write my wrapper WrappingUx.h:
It compiles but the linkage ... crash:Code:1. # include "stdafx.h" 2. # include "tux.h" 3. # pragma comment (lib, ". / tux.lib) 4. # include <msclr\auto_handle.h> 5. # pragma once 6. 7. public ref class TuxWrapper 8. ( 9. 10. private: 11. Tux m_pTux *; 12. public: 13. TuxWrapper (); 14. ~ TuxWrapper (); 15. System:: String ^ getName (); 16. );
And then I dry them outright. I tried to play with extern, __stdcall, dllexport, .... nothing to doCode:Error 1 error LNK2028: unresolved token (0A00000D) "public: char const * __stdcall Tux:: getName (void)" (? GetName Tux @ @ @ $ $ FQAGPBDXZ) referenced in function "public: class System:: String ^ __clrcall TuxWrapper :: getName (void) "(? TuxWrapper getName @ @ @ $ $ FQ $ $ AAMP AAVString @ System @ @ XZ) WrappingUx.obj WrappingUx Error 2 error LNK2019: unresolved external symbol "public: char const * __stdcall Tux:: getName (void)" (? GetName Tux @ @ @ $ $ FQAGPBDXZ) referenced in function "public: class System:: String ^ __clrcall TuxWrapper: getName (void) "(? TuxWrapper getName @ @ @ $ $ FQ $ $ AAMP AAVString @ System @ @ XZ) WrappingUx.obj WrappingUx Error 3 fatal error LNK1120: 2 unresolved externals C: \ Work \ Leny \ PPC \ Tests \ CrossCompilation \ C # \ TestDllImport \ Debug \ WrappingUx.dll WrappingUx
Someone would have any idea of the problem?
An alternative?
The info that might help?
Thank you in advance for your help.



Reply With Quote
Copyright Techfuels
Bookmarks