Page 1 of 1

Linking issues using ps2ip from within IOP

Posted: Thu Jul 07, 2005 5:18 pm
by TJ
Hi guys,


I'm pretty new to PS2 development, and trying to get to grips with making iop modules.

I'm trying to build an IRX that uses ps2ip code using the latest ps2sdk. The code I am using basically looks like this:

Code: Select all

void * rpcHandlerFunction(int command, void * buffer, int size)
{
    int s, con;
    struct sockaddr_in saddr;

    s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

    memset(&saddr, 0, sizeof(saddr));
    
    saddr.sin_family = AF_INET;
    saddr.sin_port = 80;
    IP4_ADDR(((struct ip_addr*)&(saddr.sin_addr)), 192, 168, 0, 1);

    con = connect(s, &saddr, sizeof(saddr));

    return rpcBuffer;
}
I get unresolved type errors on the socket functions when linking:
  • iop-gcc -miop -nostdlib -L/usr/local/ps2dev/ps2sdk/iop/lib -o ./iop.irx iop_main.o -lkernel -lkernel -lgcc
    iop_main.o(.text+0x20): In function `rpcHandlerFunction':
    iop_main.c: undefined reference to `lwip_socket'
    iop_main.o(.text+0x78):iop_main.c: undefined reference to `lwip_connect'
    collect2: ld returned 1 exit status
    make: *** [iop.irx] Error 1
I see that the iop/include dir has it's own ps2ip header file which appears to have exports for these functions and I checked that I am including the file in the iop dir and not the ee one.

I assume that these functions are provided by the ps2ip IRX since there aren't any libraries for the IOP except kernel, but how do I tell the linker that they won't be provided at link time?

Any ideas what I'm missing? Any help would be very appreciated.

// TJ

Posted: Thu Jul 07, 2005 7:26 pm
by pixel
IOP modules works a strange way. Importing functions from a module goes thru a special system. Look at ps2sdk's source, try to understand how the "import.lst" system works, and how it creates a .o files that has to be linked with the final irx module.

Posted: Thu Jul 07, 2005 11:00 pm
by TJ
Thanks pixel, I've got it to link now, will have to test it later.

For any other newbies looking to do this have a look at the $(PS2SDKSRC)/iop/debug/ioptrap code. Steal and modify the imports.lst and irx_imports.h files and get the rules to make a .o file from a .lst file from the Rules.make file under iop.

I expect to be back with more dumb questions soon.


// TJ

Posted: Sat Jul 09, 2005 5:18 am
by urchin
i could be completely wrong, but isn't the problem as simple as the lwip (lightweight tcpip) implementation code not being linked in?...

Posted: Sat Jul 09, 2005 7:42 pm
by pixel
Indeed, you're completely wrong, and you haven't read anything more than the first post of this thread.