[Linker Error] Unresolved external 'function_name... using assemby code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • timon
    New Member
    • Jun 2007
    • 6

    #1

    [Linker Error] Unresolved external 'function_name... using assemby code

    Hello!
    i´m trying to run a project in c++ Builder (windos) that uses assembly code.
    i assembly the code with ml.exe, then i have a .obj
    i add this .obj to the project

    then in a .cpp i write

    Code:
    extern estados(char *, char *, char *, int, int)
    and then i try to call this function just as my teachers teach me to do
    and appears that:
    [Linker Error] Unresolved external 'estados(char *, char *, char *, int, int)' referenced from C:\REDE\MAINUNI T.OBJ

    it's the first time i use assembly soutines in c++ so i don't really know what to do, but this is what a saw in every places i looked for.
    i think it could be a compiler option that i don't know or something like that.

    Thanks
  • Extremist
    New Member
    • Jan 2007
    • 94

    #2
    I know that when using normal C++ and header files, getting that error would indicate that the file just doesn't see the source .cpp file
    So just include that
    #include "file.cpp"

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      This is not correct:

      Originally posted by Extremist
      know that when using normal C++ and header files, getting that error would indicate that the file just doesn't see the source .cpp file
      So just include that
      #include "file.cpp"
      You do not #include source files. If a program has multiple source files and you #include "file.cpp" in each file you will die in the link with redefinition errors.

      What you should do is put the function prototype in the first source file and add the second source file to the build. If you are using a tool with projects, this means adding the second source file to the project.

      You can put the function prototype in the header file and then #include the header file. This helps where many source files need that function prototytpe.

      Comment

      • timon
        New Member
        • Jun 2007
        • 6

        #4
        thanks for the replies.
        But the problem is that there's no .cpp file with the implementation of the function. The function is implemented in a .asm file. Then i assembly the code to obtain a .obj.
        I have solved the problem jet by making a C project and without making changes in the code at all, but i want to use C++.
        if anyone knows hot to do that in another compiler could help me to.
        i may should start another discussion

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          How have you added the .obj of the .asm file to your C project??

          The same should work for your C++ project.

          Most of these tools allow files in projects to be a mixture of .c and .cpp. The .c files are compiled using C and the .cpp files compiled using C++.

          That is, a C++ project ddoes not need all the source files to be .cpp files.

          Comment

          Working...