Linking a C++ module to MASM ?

  • Follow


I am trying to link a C++ module in a MASM code. There is name
error as expected. Is there a way to do that ?

I tried everything I can with EXTERN, EXTERNDEF, C, PASCAL, BASIC
but can get rid of the error:

Test.Obj : error LNK2001: unresolved external symbol FCT_TEST


Erdy

0
Reply Erdemal 1/21/2007 7:20:58 AM

"Erdemal" <spamtrap@crayne.org> wrote in message 
news:45b3145e$0$426$4d4efb8e@read.news.be.uu.net...
>I am trying to link a C++ module in a MASM code. There is name
> error as expected. Is there a way to do that ?
>
> I tried everything I can with EXTERN, EXTERNDEF, C, PASCAL, BASIC
> but can get rid of the error:
>
> Test.Obj : error LNK2001: unresolved external symbol FCT_TEST
>

don't know if this helps.

I am assuming here, you don't really specify what it is you are trying to do 
exactly.


if you are trying to call a C++ function from assembler, have you tried 
making the function on the C++ end be declared as 'extern "C"'.

extern "C" {

void foo(int x, y)
{
    printf("Foo Bar %d", x*x+y*y);
}

}

on the assembler side, have you tried prepending the name with '_'.

dunno MASM, so I am guessing:
import _foo

.....

push 4
push 3
call _foo
add esp, 8


or such...

>
> Erdy
> 


..

0
Reply cr88192 1/21/2007 9:43:16 AM


Erdemal wrote:
> I am trying to link a C++ module in a MASM code. There is name
> error as expected. Is there a way to do that ?
> 
> I tried everything I can with EXTERN, EXTERNDEF, C, PASCAL, BASIC
> but can get rid of the error:
> 
> Test.Obj : error LNK2001: unresolved external symbol FCT_TEST
> 
> 
> Erdy
> 

Hello, try:
http://www.masm32.com/board/index.php?topic=39.0

0
Reply Mark 1/21/2007 5:02:35 PM

cr88192 wrote:
> "Erdemal" <spamtrap@crayne.org> wrote in message 
> news:45b3145e$0$426$4d4efb8e@read.news.be.uu.net...
>> I am trying to link a C++ module in a MASM code. There is name
>> error as expected. Is there a way to do that ?
>>
>> I tried everything I can with EXTERN, EXTERNDEF, C, PASCAL, BASIC
>> but can get rid of the error:
>>
>> Test.Obj : error LNK2001: unresolved external symbol FCT_TEST
>>
> 
> don't know if this helps.
> 
> I am assuming here, you don't really specify what it is you are trying to do 
> exactly.
> 
> 
> if you are trying to call a C++ function from assembler, have you tried 
> making the function on the C++ end be declared as 'extern "C"'.
> 
> extern "C" {
> 
> void foo(int x, y)
> {
>     printf("Foo Bar %d", x*x+y*y);
> }
> 
> }
> 
> on the assembler side, have you tried prepending the name with '_'.
> 
> dunno MASM, so I am guessing:
> import _foo
> 
> ....
> 
> push 4
> push 3
> call _foo
> add esp, 8
> 
> 
> or such...
> 
>> Erdy
>>

It works ! It's so easy when it's done.

Thanks to both of you,

Erdy

0
Reply Erdemal 1/21/2007 11:46:29 PM

3 Replies
317 Views

(page loaded in 0.478 seconds)

Similiar Articles:













7/20/2012 10:42:15 PM


Reply: