Results 1 to 5 of 5

Thread: Cross compiling C + + and C + + wrapper

  1. #1
    Godfey Roads is offline Member
    Join Date
    Jun 2009
    Posts
    54
    Rep Power
    3

    Default Cross compiling C + + and C + + wrapper

    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:

    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 compile with mingw32 on linux:

    Code:
    1.	mingw32msvc-i586-g + +-Wall-shared-o tux.cc tux.dll-Wl, - output-def, tux.def
    I turn on Windows ...
    I created the lib:

    Code:
    1.	lib / def: tux.def
    I created my VSC + + project (CLR can later call my class from C #).
    I enclose my tux.h I put tux.dll and tux.lib in the debug directory.
    I write my wrapper WrappingUx.h:

    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.	);
    It compiles but the linkage ... crash:

    Code:
    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
    And then I dry them outright. I tried to play with extern, __stdcall, dllexport, .... nothing to do

    Someone would have any idea of the problem?
    An alternative?
    The info that might help?

    Thank you in advance for your help.

  2. #2
    Jacq44 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    262
    Rep Power
    4

    Default

    your debug directory is part of the search paths. lib?

  3. #3
    Godfey Roads is offline Member
    Join Date
    Jun 2009
    Posts
    54
    Rep Power
    3

    Default

    Another project is in VC + +, I just copy the dll and lib in the output directory and ca roule (I confess I have not yet looked in visual studio where I had to specify the directory of dll and libs

    You think it is just that? For a full VS project (ie Tux.dll done in VS) it works. With Tux.dll done under mingw32-g + + / Linux, it works more

    Thank you from the hand

  4. #4
    Jacq44 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    262
    Rep Power
    4

    Default

    He is just saying it can not find the binary corresponding to your Tux.cpp: tux.lib

    Right-click your project in VS> Properties> Linker> Input> first line.

  5. #5
    Godfey Roads is offline Member
    Join Date
    Jun 2009
    Posts
    54
    Rep Power
    3

    Default

    ok. I put my lib next to my sources and includes the macro $ (intputdir) in the properties of the linkage project. (well it will prettiest in production).

    But there should still see a path to the cxx wrong:

    Code:
    Error 1 fatal error LNK1104: can not open file'........  TestDllImport  WrappingUx . Obj 'WrappingUx WrappingUx
    The. Obj are generated in the Debug directory, right?
    Another ownership change?

    thank you for your help because I get depressed (import a single class, and I galley ...)

    Otherwise, the tux.h and my method seems correct?
    An alternative?

    Well, is that even when I find what this error means ... why I am looking for. obj in InputDir ...

Similar Threads

  1. Compiling error
    By WilsonMartin in forum General Internet Terms
    Replies: 2
    Last Post: 07-15-2010, 03:17 PM
  2. Compiling error
    By WilsonMartin in forum Programming
    Replies: 2
    Last Post: 07-13-2010, 02:56 PM
  3. Using 9.1 not able to update, AT SPI registry wrapper not responding
    By Javante Illingworth in forum Linux/Free BSD
    Replies: 0
    Last Post: 12-09-2009, 11:29 AM
  4. Problem Compiling gcc
    By Francis Seellar in forum Programming
    Replies: 4
    Last Post: 11-20-2009, 11:20 AM
  5. Java ATK Wrapper 0.27.7
    By Mike Denness in forum Download Tools and Softwares
    Replies: 0
    Last Post: 08-17-2009, 07:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48