Linking issues using ps2ip from within IOP

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
TJ
Posts: 7
Joined: Thu Jul 07, 2005 4:41 pm

Linking issues using ps2ip from within IOP

Post 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
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post 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.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
TJ
Posts: 7
Joined: Thu Jul 07, 2005 4:41 pm

Post 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
urchin
Posts: 121
Joined: Thu Jun 02, 2005 5:41 pm

Post 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?...
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Indeed, you're completely wrong, and you haven't read anything more than the first post of this thread.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Post Reply