Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking assembly with C/C++

Status
Not open for further replies.

IanPallton

Programmer
Mar 27, 2002
3
SE
Hello.

i would like to know how to make a Lib file in assembly.
that i can use i VC++.

so far ive had a lot of problems, im using Masm32.
i get errors of the unresolved external kind, and i figure maybe this has to do with the calling convention ?.

oh well ive tried all i can up with, and still no luck

anyone ´know of a tutorial i should read, or of the common mistakes i could do with this ?

thanks in advance =)

 
I'm not sure, but are you actually exporting the routine's names? I believe that's needed for a DLL, although not necessarily for a standard lib library.

Also I think C prefers to add an underscore before the names, such as:
printf (something);

equals:

Invoke _printf, addr something

_printf proc something:DWORD
.
.
.
ret
_printf endp "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
I want to make a standard LIB library.

and im not sure i Export the routine names.

ive tried the "PUBLIC ProcName" way
and the ProcName PROTO :pARA1, :pARA etc

ive checked with dumpbin and it lists the ProcNames but it
adds a _ at the begining and a $8 at the end, thats the way it looks when using stdcall aye ?

in the C++ header file for the LIB i put
extern (returntype) __stdcall ProcName(PAR1,PAR2, etc);
i remove the leading _ and the signs following the ProcName.

and to read in the Lib i use the #pragma comment(lib,"LibName")

my Asm file also dictates that its
MODEL FLAT , stdcall

ive tried to make the lib with both MASM's Lib command and VC's.

the object file i make with the /c /coff commands

i just want to make this work.
thanks in advance =)



 
Can you put up what error messages you're getting?

Did you compile and link fine and then crash?

Been a long time since I did mixed-language programming... "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
ah no no no, i just get Unresolved External errors.
 
Like I said, can you put up (i.e. post) what error messages you're getting?

Like

Error 10665: Some really weird text about _YourFunction$666()
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
By the by, did you do something like this:

PUBLIC YourFunction

in your asm? "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top