spawn and socket

Hi.

I’m a new QNX 6.2.1 developer, I was developing on QNX 4.25 and I use the
spawnl() to launch proceses setting the qnx_spawn_flags, but these are no
longer supported.

I’m interested in use any spawn*() family functions that let me set the
NOZOMBIE flag in order to let the proceses die and get back all of its
resources.


In the other hand I have the followin problem with socket.
I wrote a simple program as follows:

#include <sys/socket.h>
#include <stdio.h>

int main(void){
int sock;

sock = socket(1,2,3);
printf(“sock = %d”,sock);

return 0;
}

also I compiled this way:

qcc test.c -o test

but, I got

/temp/AAA643088_cc.o: In function ‘main’:
/temp/AAA643088_cc.o(.text+0x10): undefined reference to ‘socket’
cc: /usr/bin/ntox86-ld error 1

What could be wrong?

Thanks in advance

Antonio

Antonio Diaz Couder <antonio.diazcouder@indap.com.mx> wrote:

Hi.

I’m a new QNX 6.2.1 developer, I was developing on QNX 4.25 and I use the
spawnl() to launch proceses setting the qnx_spawn_flags, but these are no
longer supported.

I’m interested in use any spawn*() family functions that let me set the
NOZOMBIE flag in order to let the proceses die and get back all of its
resources.

Responded in the spawn() thread – spawn() let’s you do it, or the
other option is signal(SIGCHLD, SIG_IGN). More detail in other thread.


In the other hand I have the followin problem with socket.
I wrote a simple program as follows:

#include <sys/socket.h
#include <stdio.h

int main(void){
int sock;

sock = socket(1,2,3);
printf(“sock = %d”,sock);

return 0;
}

also I compiled this way:

qcc test.c -o test

but, I got

/temp/AAA643088_cc.o: In function ‘main’:
/temp/AAA643088_cc.o(.text+0x10): undefined reference to ‘socket’
cc: /usr/bin/ntox86-ld error 1

qcc test.c -lsocket -o test

You need to tell it to look functions up in the socket library.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com

“David Gibbs” <dagibbs@qnx.com> escribió en el mensaje
news:c8ibka$ddd$2@inn.qnx.com

Antonio Diaz Couder <> antonio.diazcouder@indap.com.mx> > wrote:
Hi.

I’m a new QNX 6.2.1 developer, I was developing on QNX 4.25 and I use
the
spawnl() to launch proceses setting the qnx_spawn_flags, but these are
no
longer supported.

I’m interested in use any spawn*() family functions that let me set the
NOZOMBIE flag in order to let the proceses die and get back all of its
resources.

Responded in the spawn() thread – spawn() let’s you do it, or the
other option is signal(SIGCHLD, SIG_IGN). More detail in other thread.

\

In the other hand I have the followin problem with socket.
I wrote a simple program as follows:

#include <sys/socket.h
#include <stdio.h

int main(void){
int sock;

sock = socket(1,2,3);
printf(“sock = %d”,sock);

return 0;
}

also I compiled this way:

qcc test.c -o test

but, I got

/temp/AAA643088_cc.o: In function ‘main’:
/temp/AAA643088_cc.o(.text+0x10): undefined reference to ‘socket’
cc: /usr/bin/ntox86-ld error 1

qcc test.c -lsocket -o test

You need to tell it to look functions up in the socket library.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com

Thanks David, it worked very well.

“Antonio Diaz Couder” <antonio.diazcouder@indap.com.mx> escribió en el
mensaje news:c8ijvc$jqm$1@inn.qnx.com

“David Gibbs” <> dagibbs@qnx.com> > escribió en el mensaje
news:c8ibka$ddd$> 2@inn.qnx.com> …
Antonio Diaz Couder <> antonio.diazcouder@indap.com.mx> > wrote:
Hi.

I’m a new QNX 6.2.1 developer, I was developing on QNX 4.25 and I use
the
spawnl() to launch proceses setting the qnx_spawn_flags, but these are
no
longer supported.

I’m interested in use any spawn*() family functions that let me set
the
NOZOMBIE flag in order to let the proceses die and get back all of its
resources.

Responded in the spawn() thread – spawn() let’s you do it, or the
other option is signal(SIGCHLD, SIG_IGN). More detail in other thread.


\

In the other hand I have the followin problem with socket.
I wrote a simple program as follows:

#include <sys/socket.h
#include <stdio.h

int main(void){
int sock;

sock = socket(1,2,3);
printf(“sock = %d”,sock);

return 0;
}

also I compiled this way:

qcc test.c -o test

but, I got

/temp/AAA643088_cc.o: In function ‘main’:
/temp/AAA643088_cc.o(.text+0x10): undefined reference to ‘socket’
cc: /usr/bin/ntox86-ld error 1

qcc test.c -lsocket -o test

You need to tell it to look functions up in the socket library.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com

Thanks David, it worked very well.

Now I have some similar problems with pow(), sqrt(), exp().
Is there any documentation on how to specify to find each function?

Hi Antonio…

Ok, make sure that when you compile, you specify the math library:

qcc -o prog prog.c -lm

Go to Barnes & Noble and get a book on C/C++. Also search for C/C++
tutorials on the web, etc (a search for ‘c/c++ tutorial’ yielded over
10000 hits). These things will help you greatly.

Regards…

Miguel.


Antonio Diaz Couder wrote:

Now I have some similar problems with pow(), sqrt(), exp().
Is there any documentation on how to specify to find each function?

Antonio Diaz Couder <antonio.diazcouder@indap.com.mx> wrote:


Now I have some similar problems with pow(), sqrt(), exp().
Is there any documentation on how to specify to find each function?

For each function, in the function header there is a “Library:” entry.
This tells what library needs to be linked – e.g. for pow() it says:

Library:

libm

But, what it does tell anywhere that I can find is that “libm” there
means to pass “-lm” to qcc for the link stage of your compilation. That
needs to be documented somewhere, and I’ll issue a PR for it.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com