I'm writing a little equation solver for an exam ... it has not to be perfect or mathematically rigorous. With this program I have only to show to my professor that I can write some simple program in Assembly and C++ language. In other words, I have only to show if I have understood the basis of Assembly language. I'm referring to x86 Assembly Language.
Here's the source code: there are some c++ classes and assembly functions:

(I cannot post all the source code because it's too long for the posting form, I'm uploading it to my dropbox folder, please download it).

FILE 1: http://dl.dropbox.com/u/3371514/class_razionali_debug.cpp
FILE 2: http://dl.dropbox.com/u/3371514/equa.s
FILE 3: http://dl.dropbox.com/u/3371514/rad.cpp

It's obvious that this source cod isn't complete (I'm going to finish it during the next days) but it should compile. It doesn't. I'm under linux (ubuntu) and I'm trying to compile it using these commands:

g++ -c -o equa_s.o equa.s -g3 -m32
g++ -c -o rad.o rad.cpp -g3 -m32
g++ -c -o equa_c.o class_razionali_debug.cpp -g3 -m32
g++ -o equa.out equa_s.o equa_c.o rad.o -g3 -m32

But when I try to link all the object files I get this error message:
equa_s.o: In function `second_grade_comp_solver':
/home/gianx80/Documenti/equa.s:81: undefined reference to `rad'

So, how can I compile my program without errors?

7 Years
Discussion Span
Last Post by Salem

Just like C and C++ you have to prototype the functions that you want to call. That function "rad" does not appear anywhere in that file except the call statement.


The rad function is located in the rad.cpp file. In which of the three files I have to prototype it?


I solved the problem. I used the extern "C" and merged the rad.cpp file with the class_razionali_debug.cpp file.
If I mantain the three files organization, the source code won't link.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.