Error message of compiling a C code


 
Thread Tools Search this Thread
Top Forums Programming Error message of compiling a C code
# 1  
Old 03-11-2008
Error message of compiling a C code

Hi,

Recently I have a C Code and i compile on my pc with

gcc -D _t_1 -o a.out test.c

It works fine for me on my pc. However, upon transferring the same code on Sun Solaris server, it breaks with the below message:-

Undefined first referenced
symbol in file
trunc /var/tmp//ccOdHYd0.o
ld: fatal: Symbol referencing errors. No output written to c.exe
collect2: ld returned 1 exit status


I am not so sure what causing the problem. Because I assume it shall work in all cases since it work on my pc. Can anyone point me any clue/hints to the above problem.

Thanks.Appreciate alot.


I forgot to mention that the trunc actually referring to below:-

double trunc(double);

typedef double Point;
#define rand_0_n(n) trunc((double)(drand48()*(n)))

Last edited by ahjiefreak; 03-11-2008 at 08:03 PM..
# 2  
Old 03-12-2008
Link the math lib "-lm" at compile time.

Code:
gcc -lm -D _t_1 -o a.out test.c

# 3  
Old 03-12-2008
Hi Shamrock,

I did include -lm flag in my command.

gcc -D _t_1 -o a.out test.c -lm

I changed to (floor) but there is no output from ./a.out

Please advise. THanks.
# 4  
Old 03-12-2008
Has the compile time error has gone after linking the math lib into the executable? Without looking at the code it is not possible to figure out what inputs are given to floor().
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Error while compiling

Hi I am trying to compile a binary file (CASPER: Context-Aware Scheme for Paired-End Read) but I am getting the following error: user@user-OptiPlex-780 make g++ -O2 -Wall -fopenmp -c -o merge.o merge.c merge.c:8:35: fatal error: boost/unordered_map.hpp: No such... (2 Replies)
Discussion started by: Xterra
2 Replies

2. UNIX for Dummies Questions & Answers

CPT test exam compiling code

Hello all I am new to programming and trying to compile this code #include <asm/unistd.h> #include <sys/mman.h> #include <unistd.h> #include <errno.h> #define MREMAP_MAYMOVE 1 #define MREMAP_FIXED 2 #define __NR_real_mremap __NR_mremap static inline _syscall5( void *,... (2 Replies)
Discussion started by: crustymonkey
2 Replies

3. Shell Programming and Scripting

Compiling source code issue

Need assistance in compile a source code with PERL flags Compile source code CDFconvert-2.2.3 which requires Fortran 90,Perl interpreter , Perl/TK module , NetCDF library , Gempak I have all the above required libraries . Issue is when compiling the source code it looks for local... (4 Replies)
Discussion started by: ajayram_arya
4 Replies

4. Solaris

ERROR while compiling

Hi guys i came across an error while compiling a c file in solaris using gcc. the error is, Undefined first referenced symbol in file bind /var/tmp//ccAr8qAh.o accept ... (4 Replies)
Discussion started by: rajeshb6
4 Replies

5. Programming

Problems compiling code

I am trying to compile some code and getting lot of errors g++ -traditional -Wno-non-template-friend -Wno-deprecated -O3 -DNDEBUG -DREAL=float -DGetREAL=Getfloat -IbaseLib -Itommy -Iothers ./source/main/RayTrac.cc -o raytrac ./source/main/RayTrac.cc:36:20: error: gendef.h: No such file or... (1 Reply)
Discussion started by: kristinu
1 Replies

6. Programming

Compiling and running Python code

Hey there, First post here in the Unix forums, but I have used them a lot for research over the last year. Anyways, to why I'm here now: I'm working on a project and I'll be using the AIS Parser SDK by Brian C. Lane (can't post the link, but google that and the first 8 links will be relevant) ... (4 Replies)
Discussion started by: pmd006
4 Replies

7. Programming

Error with compiling

Hi guys. I have a header file: unp.h like this: #ifndef _UNP_H_ #define _UNP_H_ extern ssize_t readn(int filedes, void *buff, size_t nbytes); extern ssize_t writen(int filedes, const void *buff, size_t nbytes); extern void err_quit(const char *msg); #define TRUE 1 #define FALSE 0 ... (2 Replies)
Discussion started by: majid.merkava
2 Replies

8. Windows & DOS: Issues & Discussions

Problem compiling C++ Code in Cygwin

Hello everyone. I just recently installed Cygwin and I am running it under Windows 7. My problem is that I cannot seem to compile any C++ code with g++. I've tried to compile C Code using gcc and that works just fine. But Whenever I try to compile some C++ code, g++ throws a whole bunch of... (6 Replies)
Discussion started by: Anlex
6 Replies

9. Programming

Compilation error when compiling Pro*C code

I'm running a query similar to the one that I'm describing below -: _______________________________ EXEC SQL INSERT INTO TABLE1 ( C1 ,C2 ,C3 ,C4 ) (SELECT DISTINCT B.V1 ,B.V2 ,( SELECT D.V3 FROM TABLE2 D WHERE D.V3 = C.V4) ,B.V4 FROM TABLE2 B ,TABLE3 C WHERE B.V3 = C.V4) ;... (1 Reply)
Discussion started by: maheshp
1 Replies

10. UNIX for Dummies Questions & Answers

Compiling Code

Hi i am new to programming im having a bit of a problem i have installed kubuntu on my computer and i have wrote some code but when i go to compile it i get this error in the terminal ross@ubuntu:~/cp1$ g++ -ansi -pedantic array.cpp -o array ross@ubuntu:~/cp1$ array The program 'array' is... (3 Replies)
Discussion started by: RossMc
3 Replies
Login or Register to Ask a Question