Mail Archives: djgpp/1998/06/15/00:02:29
Ben wrote:
>
> When I try to compile using Rhide it gives me this error message:
> Error: c:/djgpp/bin/ld.exe: cannot open -lstdcx: No such file or directory
> (ENOENT)
>
> I really don't understand why it can find something (I downloaded all the
> files I should have).
> Can someone help?
Read the file c:\djgpp\gnu\gcc-2.81\problems.txt.
--
Nate Eldredge
nate AT cartsys DOT com
-----------------------------------------
>
> with
>
> --[test.c]--------------------------------------------------
> extern int My_function();
>
> void main()
> {
> printf("Result=%d\n", My_function());
> return;
> }
> ------------------------------------------------------------
>
> it compiles ok. But if I change file name from test.c to objective
> test.cc it doesn't. It says "Undefined reference to My_function(void)"
That's because in C++, the compiler mangles names in order to be able to
distinguish between `void foo(int)' and `void foo(double)', and so
forth. Your assembler name is not mangled, so it doesn't get found.
Declare your asm function as extern "C" in the C++ source, and
everything will be fine.
Btw, `main' has to return `int'.
> 2. When I write:
>
> --[file.asm]------------------------------------------------
> [BITS 32]
> [GLOBAL _My_function__FUi]
> [SECTION .text]
>
> _My_function__FUi:
> mov ax, 1010
> ret
> ------------------------------------------------------------
>
> with
>
> --[test.c]--------------------------------------------------
> extern int My_function(unsigned int);
>
> void main()
> {
> printf("Result=%d\n", My_function(23));
> return;
> }
> ------------------------------------------------------------
>
> it says "Undefined reference to My_function". Why?
> Please help me.
Opposite side of the same coin, as above. The C compiler does not
mangle names, so if you try to do it, it will just get confused.
Summary: Declare your assembly functions with normal names, and declare
them extern "C" if you want to access them from C++.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -