Compilation C program


 
Thread Tools Search this Thread
Top Forums Programming Compilation C program
# 1  
Old 01-06-2012
Compilation C program

Hi guys...
Im trying to compile a program written in C..
I am able to compile it to X86, especifically Ubuntu..
But i cant compile it to mips ar71xx architecture..
im using mips-linux-uclibc-gcc cross compiler.
Code:
this is the portion of code:
//STAT: LOGIN INFO
    // 3. login info
    i = cs_message_receive(sock, &clicd, buf, sessionkey);
    ticks = GetTickCount()-ticks;
    if (i<=0) {
        close(sock);
        if (tid) pthread_join(tid, NULL);
        pthread_exit();
    }
    if (buf[0]!=MSG_CLIENT_2_SERVER_LOGIN) {
        close(sock);
        if (tid) pthread_join(tid, NULL);
        pthread_exit();
    }
    index = 3;
    // Check username
    struct twin_client_data *usr = cfg.client;
    int found = 0;
    while (usr) {
        if (!strcmp(usr->user,&buf[index])) {
            found=1;
            break;
        }
        usr = usr->next;
    }
    if (!found) {
        buf[0] = MSG_CLIENT_2_SERVER_LOGIN_NAK;
        buf[1] = 0;
        buf[2] = 0;
        cs_message_send(sock, NULL, buf, 3, sessionkey);
        debug("newcamd: unknown user '%s' (%s)\n", &buf[3], ip2string(ip));
        close(sock);
        if (tid) pthread_join(tid, NULL);
        pthread_exit();
    }

i get this error when compiling on uclibc
Code:
mips-linux-uclibc-gcc -c -O2 -I. main.c -o main.o
<built-in>:0: note: someone does not honour COPTS correctly, passed 0 times
main.c: In function 'th_cs_connect_cli':
main.c:196: error: too few arguments to function 'pthread_exit'
main.c:201: error: too few arguments to function 'pthread_exit'
main.c:222: error: too few arguments to function 'pthread_exit'
main.c:257: error: too few arguments to function 'pthread_exit'
make[4]: *** [main.o] Error 1

the line 196 correspond to the first pthread_exit() funtion that appears in the code.
Im not very familiar with C programming..
I also waas reading the pthread_exit() usage and i could not clear my doubts..

This is my makefile file:
Code:
#CC    = gcc
CXX    = g++
STRIP    = strip
CFLAGS    = -O2 -I.
LFLAGS    = -pthread

OBJECTS = tools.o convert.o debug.o des.o md5crypt.o sockets.o serial.o newcamd.o config.o threads.o main.o

link : $(OBJECTS)
    $(CC) $(LFLAGS) -o twin2cs $(OBJECTS)
.c.o:
    $(CC) -c $(CFLAGS) $< -o $@

clean:
    -rm *.o

# 2  
Old 01-06-2012
BY standard: pthread_exit() requires one argument, it can be NULL.

Sometimes the implementation of a compiler for a given platform can behave in an out-band-way. Change the code & recompile.
# 3  
Old 01-07-2012
thanks for reply

Well, in fact i did.. I putted NULL value to the funtion pthread_exit() and it compiled OK
But, when I execute the program it bahaves in a wrong way...
For example: that code upside, correspond to the Log In of the client to the server.
It start the server. Until that point it's OK
Then when a user want to Log in, it rejects all connections, the logic has change..
So, the point think. How could I know how the ubuntu compiler deal with this part?
I mean, what the ubuntu compiler does when it has to compile it? It ommit it? Add a predefined value? Just Ignore?
I tried to see the ubuntu compiler debug, but what i see I did not understand..
# 4  
Old 01-07-2012
The only way to see what is really going on is to look what assembly code is generated by g++ and then use a debugger to step though the code. You can use the gcc/g++ -S option to output assembly code.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compilation

Hi All, Do we have a way to compile a shell program? I am using ksh/bash/sh and not CSH. Cheers Ravi (12 Replies)
Discussion started by: panyam
12 Replies

2. UNIX for Dummies Questions & Answers

proc program compilation in unix

hi, i need to compile a proc program, say prog.pc can we compile this program in the unix environment? does this need a make file? can anyone help me on this since i am new to this area. Thanks in advance. (1 Reply)
Discussion started by: csprog
1 Replies

3. AIX

Problem in compilation.

Hi, I am executing the below mentioned code:- proc SQLCHECK=SEMANTICS iname=CDBInteractor.pc parse=none code=cpp cpp_suffix=cpp g++ -c main.cpp g++ -o pre_request_engine main.o -I/oracle/oracle/app/product/10g/precomp -L/oracle/oracle/app/product/10g/lib32 -lnsl -ldl And... (2 Replies)
Discussion started by: tushar_tus
2 Replies

4. Programming

Program exited with code 01: does it indicate unsuccessful compilation?

(gdb) r --------------------- enter Breakpoint 1, 0x0000000000409d40 in main () (gdb) n Single stepping until exit from function main, which has no line number information. Find_Cmd_Option: found option no. 2: seed (s) Find_Cmd_Option: found option no. 5: dfile (c) Initial no. div... (1 Reply)
Discussion started by: cdbug
1 Replies

5. UNIX for Dummies Questions & Answers

Compilation

Hi All, We have a C program existing in one of the folders which I have to modify a lil bit, When I'm trying to compile the program using GCC or CC command its showing as ksh: gcc: not found is that mean there is no compiler or do I have to verify for something, please advice Thank... (2 Replies)
Discussion started by: diggermf
2 Replies

6. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

7. UNIX for Dummies Questions & Answers

Compilation program

Hi, I'm new to HP-Unix programming; I have a few programs, don't know the programming language used. I have to make minor changes and to recompile the source code. How do I find the programming language used and the compiler? Thanks, Nick. (3 Replies)
Discussion started by: NicoMan
3 Replies

8. UNIX for Dummies Questions & Answers

multifile c program compilation and execution

i am using unix os and my program is divided in two text files .:):) how to compile and make one executable file, using unix command. (1 Reply)
Discussion started by: alokmishra8
1 Replies

9. UNIX for Dummies Questions & Answers

Kernel compilation

I have re-compiled kernel source code available in /usr/src/linux.2.4.20 with "make" command. The compilation is succesful. Now the problem is create the image for this. The documentation in the same folder says that now you have compile "make image". There is no option for image in Makefile. ... (3 Replies)
Discussion started by: mankrish
3 Replies

10. Programming

compilation error

Hi, While trying compile a C++ file in UNIX with gcc whose make rule involves the usage of /usr/ccs/bin/as, I get the following error: /usr/ccs/bin/as: No such file or directory /usr/ccs/bin/as: error: write error on output file "<filename>.o" *** Error code 1 clearmake: Error: Build... (2 Replies)
Discussion started by: smanu
2 Replies
Login or Register to Ask a Question