error linking c++ and asm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xmaryposax
    New Member
    • Nov 2010
    • 2

    error linking c++ and asm

    i want to call a procedure from asm but when i want to link my program it show some error
    like de _cout procedure doesn't exist and _printf and others =/.....
    i think that maybe the obj of my program in c++ its not right but how i make it!! i use borland c++ 4.5
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    C++ uses name mangling, that is the function name os not the actual name you give it, which is required to support function overloading.

    If you want to call an assembler function or call a function from an assembly routine then you are better off declaring it as a C function. C does not use name mangling (and does not support function overloading) and so it is easier to translate the name correctly for the assembly code.

    Normally the name in assembly is the same as the name in C with a prepended _

    Comment

    • Raj K
      New Member
      • Dec 2010
      • 9

      #3
      - From the assembly you need to call mangled name instead of the name that appears in C++ code.
      - Different compilers use different strategies for name mangling.
      - Here is name mangling described. This article uses g++ as compiler. You need to explore your compiler behavior for the same.
      Here is the link -


      - If the link error is due to your C++ code, then look for extern keyword, it might help

      Comment

      • xmaryposax
        New Member
        • Nov 2010
        • 2

        #4
        thanks, but i did'nt work, it was the same that i had done ='( i'll try with the g++ compiler like you said

        Comment

        Working...