starpu-runtime / starpu

This is a mirror of https://gitlab.inria.fr/starpu/starpu where our development happens, but contributions are welcome here too!
https://starpu.gitlabpages.inria.fr/
GNU Lesser General Public License v2.1
63 stars 12 forks source link

Linking problem when using out-of-core functions with g++ #41

Closed lavar3l closed 8 months ago

lavar3l commented 8 months ago

Hi,

I have run into a problem when trying to enable out-of-core for StarPU in a C++ project.

The functions from _starpudisk.h header file (for example : starpu_disk_register) are not found by the linker when I include starpu.h as C++ header : undefined reference to 'starpu_disk_register(starpu_disk_ops*, void*, long)'.

However they are linked correctly when the header is included as C header, for example:

extern "C" {
#include <starpu.h>
}

Steps to reproduce

In order to reproduce the problem I have prepared a small example:

#include <starpu.h>

int main(int argc, char **argv)
{
    if (starpu_init(NULL)) {
        return 1;
    }

    int dd = starpu_disk_register((struct starpu_disk_ops*)&starpu_disk_unistd_ops, (void*)"/tmp/", (starpu_ssize_t)(1024 * 1024 * 100));
    if (dd == -ENOENT) {
        return 77;
    }

    starpu_shutdown();
}

To reproduce the issue, build the minimal reproducible example file with gcc and g++ compilers:

Notice the linking issue with starpu_disk_register function when StarPU is compiled using g++, but not when using gcc.

Obtained behavior

Linking fails when g++ is used :

/usr/bin/ld: /tmp/ccM3c7jw.o: in function `main':
outofcore_mre.c:(.text+0x62): undefined reference to `starpu_disk_register(starpu_disk_ops*, void*, long)'
collect2: error: ld returned 1 exit status

Compilation and linking are completed successfully when using gcc.

Expected behavior

Out-of-core functions compile and link correctly when StarPU is compiled using g++ compiler, and imported as a C++ header.

Configuration

../configure --prefix=$INSTALL_DIR/starpu-fxt --disable-opencl --disable-build-doc --disable-build-examples --disable-build-test --with-fxt=$INSTALL_DIR/fxt --enable-hdf5 --enable-bubble

Configuration result

config.log

Distribution

Git (tags/starpu-1.4.1)

Version of StarPU

StarPU 1.4.1 It is also reproducible on StarPU 1.4.3.

Version of GPU drivers

N/A

Thank you in advance for your help and advice.

Best regards, Przemyslaw DOMINIKOWSKI

sthibaul commented 8 months ago

extern "C" was indeed missing in the starpu_disk.h header, now fixed on gitlab, will propagate to github within a day, thanks!

lavar3l commented 8 months ago

Thank you very much!