We have installed GCC and libgcc on AIX.
I am busy compiling a C library on the machine and keep getting the following error:
Undefined symbol: .main
Any idea how to solve this?
Thanks for the help
Lynton
You are most likely using the wrong gcc arguments - probably you are using the same ones you'd use for an executable program (where main() is required). The correct arguments depend on what kind of library you want to build (a static one or a dynamic (.so) one)
Related
We are porting an application from HPUX to Linux using Microfocus COBOL and GNU C on both platforms.One of our shared libraries is failing at runtime with the following error:
AB123: symbol lookup error. libRTS.so: undefined symbol: _mFldhandle
My understanding is that _mFldhandle is internal to Microfocus.
Can anyone point me to why we might be having an issue / what we should be including to make sure _mFldhandle is available at runtime?
Thanks!
Contrary to the comments from above the usual reason for this symbol being missing is not using "cob" to link your exe or shared object.
The other reason is not using the same 'C' compiler that the product was created with.
I am trying to compile a hello world program in C on a Linux 64-bit machine. I am using an ARM cross compiler to load my application onto an ARM processor. However, when compiling the code using arm-none-eabi-gcc -o hello hello.c I get a series of errors:
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o): In function exit':
exit.c:(.text.exit+0x2c): undefined reference to_exit'
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function _sbrk_r':
sbrkr.c:(.text._sbrk_r+0x18): undefined reference to_sbrk'
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function _write_r':
writer.c:(.text._write_r+0x20): undefined reference to_write'
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function _close_r':
closer.c:(.text._close_r+0x18): undefined reference to_close'
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function _fstat_r':
fstatr.c:(.text._fstat_r+0x1c): undefined reference to_fstat'
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function _isatty_r':
isattyr.c:(.text._isatty_r+0x18): undefined reference to_isatty'
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function _lseek_r':
lseekr.c:(.text._lseek_r+0x20): undefined reference to_lseek'
/home/dico/gcc-arm-none-eabi-4_7-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function _read_r':
readr.c:(.text._read_r+0x20): undefined reference to_read'
collect2: error: ld returned 1 exit status
When I try compiling by doing: arm-none-eabi-gcc -c hello.c, it creates an object code hello.o which tells me that the compiler runs fine.
Could someone perhaps tell me why my compilation is return such errors please?
UPDATE
I realize now that the C runtime library isn't included in the compilation. Does anyone know of any options I need to include in the compilation or how to link the library to be able to use standard functions such as printf for example?
What should the MCU chip do with a printf string since there is no console? That's what is happening. libc needs low level functions that is platform dependent and shall not be included in the libc.
You need a retarget.c or a syscalls.c file that defines all these missing symbols and properly retarget the printf output to a serial line that you have access from the outside of the chip.
I strongly recommend you to use the yagarto toolkit, they provide a syscall.c file with what's necessary to build a project when linking against libc, as you are doing.
If you want to try the short path, include the syscall.c file to your project and reprogram its functions internals to suit your needs.
Linking bare gcc toolchain against libc in the microcontroller world is not for beginners. My recommendation is always to follow step by step yagarto's tutorials.
So, I have TVZLib.h, TVZlib.dll, and TVZlib.lib, and I am using gcc to compile the following program (it's a simple test case). The complier gives me the error:
"undefined reference to '_imp__TVZGetNavigationMatrix'"
Yet. when I comple the program with a different type of parameter for the function's call, it complains that it's not the correct parameter (requires *float). To me, that means that it at least has found the function, as it knows what it wants.
From my research, I can tell that people think it's to do with the linking of the library, or the order in which I link, but I've tried all of the gcc commands in all combinations, and all give me the same error, so I'm desperate for some help.
#include <stdlib.h>
#include <stdio.h>
#include "TVZLib.h"
int main() {
float floatie = 2;
float *ptr = &floatie;
TVZGetNavigationMatrix(ptr);
getchar();
return 0;
}
Thanks a lot in advance!
My compiler command:
gcc dlltest.c -L. TVZLib.lib
The header file (TVZLib.h).
And the direct output:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccuDpoiE.o:dlltest.c:(.text+0x2c): undefined reference to `_imp__TVZGetNavigationMatrix'
collect2: ld returned 1 exit status
It's been a while since I've been compiling natively on Windows...
Did you intend to link statically against TVZlib.lib? That's not happening.
By default, gcc will pick the dynamic version of a library if it finds both a static and a dynamic lib. If you want to force gcc to link statically, you can use the -static option.
If memory serves me right the _imp__ prefix is a sign that a DLL was loaded (_imp__ symbol prefix is used for the trampoline function that calls into the DLL).
When I link my MPI C program, I get the following error:
undefined reference to MPI_recv.
What should i do to solve this error?
It is MPI_Recv, not MPI_recv.
You need to link to the MPI library that provides the MPI_recv() function. For example, with gcc, you would add an option like -lmpi to your compile line.
MPI implementations usually provide a compilation utility scripts that basically sets up the correct compilation & linking environment, libraries and calls gcc (e.g.) with the correct command line.
Try this:
mpicc my_prog.c
Hope this helps.
A.
In my Turbo C++ program, I can't run any of the graphics program. When it compiles, it shows an error like:
undefined symbol _line, _closegraph,_ getmaxx etc...
Is it due to the settings of my c-program?
Is this an old program that was written for Turbo C++, and that you're trying to compile with a modern compiler? If so, it might be the case that the program uses compiler-specific extensions and libraries, that are simply not available in the compiler you're using now.
If that is the case, you must either
find an existing library for your current environment that emulates the old Turbo C++ one, or
find out exactly what each call is supposed to do, and change the code to use something that your environment supports.
It's compile error and not link error. Looks like "graphics.h" is missing.
Do
#include "graphics.h"
Those errors are typical of a missing library in your build. Try linking the appropriate libraries and rebuild the solution (most likely graphics.lib).
-John
If the problem is of compiling error then you may add the header file:
#include<graphics.h>
if the problem still persists then make sure you have added the header file:
#include<dos.h>