The MulticoreBSP Forums

A place to discuss the MulticoreBSP library and its applications, and for discussing the use of the Bulk Synchronous Parallel model on shared-memory architectures, or hybrid distributed/shared architectures.

You are not logged in.

#1 2014-01-17 17:33:09

finao13
New member
Registered: 2014-01-17
Posts: 1

Bug Trying To Implement MulticoreBSP with JNI on W7 64 bits

Hi,

I'm trying to call the bsp functions (through the header mcbsp.h) from a .c file used within JNI.

But when building the Dll with x86_64-w64-mingw32-gcc through Code::Blocks it throws:
Linker mcbsp used: http://www.multicorebsp.com/downloads/c/1.1.0/win32/libmcbsp1.1.0.a

C:/Users/.../main.c:36: undefined reference to `bsp_nprocs'
C:/Users/.../main.c:37: undefined reference to `bsp_begin'
C:/Users/.../main.c:38: undefined reference to `bsp_nprocs'
C:/Users/.../main.c:39: undefined reference to `bsp_pid'
C:/Users/.../main.c:42: undefined reference to `bsp_push_reg'
C:/Users/.../main.c:43: undefined reference to `bsp_sync'
C:/Users/.../main.c:91: undefined reference to `bsp_put'
C:/Users/.../main.c:92: undefined reference to `bsp_put'
C:/Users/.../main.c:94: undefined reference to `bsp_sync'
C:/Users/.../main.c:108: undefined reference to `bsp_pop_reg'
C:/Users/.../main.c:111: undefined reference to `bsp_end'

Contrariwise, when building the Dll with x86_64-w64-mingw32-gcc through Code::Blocks but with
Linker mcbsp: http://www.multicorebsp.com/downloads/c/1.1.0/win64/libmcbsp1.1.0.a

I've got those errors:

/home/albert/Documents/1.1.0/mcbsp.c:251: undefined reference to `__imp_pthread_mutex_init'
/home/albert/Documents/1.1.0/mcbsp.c:267: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcbsp.c:314: undefined reference to `__imp_pthread_attr_init'
/home/albert/Documents/1.1.0/mcbsp.c:326: undefined reference to `__imp_pthread_create'
/home/albert/Documents/1.1.0/mcbsp.c:334: undefined reference to `__imp_pthread_getw32threadhandle_np'
/home/albert/Documents/1.1.0/mcbsp.c:366: undefined reference to `__imp_pthread_attr_destroy'
/home/albert/Documents/1.1.0/mcbsp.c:394: undefined reference to `__imp_pthread_self'
/home/albert/Documents/1.1.0/mcbsp.c:396: undefined reference to `__imp_pthread_setspecific'
/home/albert/Documents/1.1.0/mcbsp.c:267: undefined reference to `__imp_pthread_getspecific'
C:\Users\...\libmcbsp1.1.0.a(mcbsp.o): In function `bsp_end':
/home/albert/Documents/1.1.0/mcbsp.c:443: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcbsp.c:459: undefined reference to `__imp_pthread_setspecific'
/home/albert/Documents/1.1.0/mcbsp.c:494: undefined reference to `__imp_pthread_join'
/home/albert/Documents/1.1.0/mcbsp.c:501: undefined reference to `__imp_pthread_mutex_destroy'
/home/albert/Documents/1.1.0/mcbsp.c:487: undefined reference to `__imp_pthread_exit'
C:\Users\...\lib\libmcbsp1.1.0.a(mcbsp.o): In function `bsp_nprocs':
/home/albert/Documents/1.1.0/mcbsp.c:558: undefined reference to `__imp_pthread_getspecific'
C:\Users\...\lib\libmcbsp1.1.0.a(mcbsp.o): In function `bsp_vabort':
/home/albert/Documents/1.1.0/mcbsp.c:613: undefined reference to `__imp_pthread_exit'
/home/albert/Documents/1.1.0/mcbsp.c:613: undefined reference to `__imp_pthread_exit'
C:\Users\...\libmcbsp1.1.0.a(mcbsp.o): In function `bsp_sync':
/home/albert/Documents/1.1.0/mcbsp.c:618: undefined reference to `__imp_pthread_getspecific'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `mcbsp_internal_check_keys_allocated':
/home/albert/Documents/1.1.0/mcinternal.c:113: undefined reference to `__imp_pthread_mutex_lock'
/home/albert/Documents/1.1.0/mcinternal.c:145: undefined reference to `__imp_pthread_mutex_unlock'
/home/albert/Documents/1.1.0/mcinternal.c:117: undefined reference to `__imp_pthread_key_create'
/home/albert/Documents/1.1.0/mcinternal.c:129: undefined reference to `__imp_pthread_setspecific'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `bsp_begin_check':
/home/albert/Documents/1.1.0/mcinternal.c:40: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcinternal.c:67: undefined reference to `__imp_pthread_setspecific'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `mcbsp_internal_getMachineInfo':
/home/albert/Documents/1.1.0/mcinternal.c:81: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcinternal.c:85: undefined reference to `__imp_pthread_setspecific'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `bsp_init_internal':
/home/albert/Documents/1.1.0/mcinternal.c:95: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcinternal.c:102: undefined reference to `__imp_pthread_setspecific'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `mcbsp_internal_spmd':
/home/albert/Documents/1.1.0/mcinternal.c:153: undefined reference to `__imp_pthread_setspecific'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `mcbsp_internal_check_aborted':
/home/albert/Documents/1.1.0/mcinternal.c:195: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcinternal.c:204: undefined reference to `__imp_pthread_exit'
/home/albert/Documents/1.1.0/mcinternal.c:195: undefined reference to `__imp_pthread_getspecific'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `mcbsp_internal_syncWithCondition':
/home/albert/Documents/1.1.0/mcinternal.c:204: undefined reference to `__imp_pthread_exit'
C:\Users\...\libmcbsp1.1.0.a(mcinternal.o): In function `mcbsp_internal_check_aborted':
/home/albert/Documents/1.1.0/mcinternal.c:195: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcinternal.c:204: undefined reference to `__imp_pthread_exit'
/home/albert/Documents/1.1.0/mcinternal.c:195: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcinternal.c:204: undefined reference to `__imp_pthread_exit'
/home/albert/Documents/1.1.0/mcinternal.c:195: undefined reference to `__imp_pthread_getspecific'
/home/albert/Documents/1.1.0/mcinternal.c:204: undefined reference to `__imp_pthread_exit'
C:\Users\...\libmcbsp1.1.0.a(mcutil.o): In function `mcbsp_util_address_table_initialise':
/home/albert/Documents/1.1.0/mcutil.c:645: undefined reference to `__imp_pthread_mutex_init'
C:\Users\...\libmcbsp1.1.0.a(mcutil.o): In function `mcbsp_util_address_table_setsize':
/home/albert/Documents/1.1.0/mcutil.c:697: undefined reference to `__imp_pthread_mutex_lock'
/home/albert/Documents/1.1.0/mcutil.c:702: undefined reference to `__imp_pthread_mutex_unlock'
C:\Users\...\libmcbsp1.1.0.a(mcutil.o): In function `mcbsp_util_address_table_destroy':
/home/albert/Documents/1.1.0/mcutil.c:714: undefined reference to `__imp_pthread_mutex_destroy'
C:\Users\...\libmcbsp1.1.0.a(mcutil.o): In function `mcbsp_util_address_table_setsize':
/home/albert/Documents/1.1.0/mcutil.c:697: undefined reference to `__imp_pthread_mutex_lock'
/home/albert/Documents/1.1.0/mcutil.c:702: undefined reference to `__imp_pthread_mutex_unlock'
c:/mingwx64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function `main':
c:\bb\vista64-mingw32\mingw-x86-x86_64\build\build\mingw\obj/../../../build/mingw/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `__mingw_winmain_nShowCmd'
c:\bb\vista64-mingw32\mingw-x86-x86_64\build\build\mingw\obj/../../../build/mingw/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `__mingw_winmain_lpCmdLine'
c:\bb\vista64-mingw32\mingw-x86-x86_64\build\build\mingw\obj/../../../build/mingw/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `__mingw_winmain_hInstance'
c:\bb\vista64-mingw32\mingw-x86-x86_64\build\build\mingw\obj/../../../build/mingw/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'

I have to say that when using MulticoreBSP alone (without JNI) I've got no problem of compilation. In the same way if I use separately JNI (without calling bsp functions), I've got again no problem of compilation.

Any ideas what could be the problem?

Offline

#2 2014-01-18 18:13:34

Albert-Jan Yzelman
Moderator
Registered: 2011-08-04
Posts: 28

Re: Bug Trying To Implement MulticoreBSP with JNI on W7 64 bits

As a note: this question is about calling MulticoreBSP for C from Java. Note that there's also a native Java version available.

As for the question, with part one, you're using a 64-bit compiler but linking against a 32-bit library; hence the BSP functions are not recoginised. For part two, the BSP functions are recognised by the linker, but the MulticoreBSP for C library depends on POSIX Threads, which is not found by the linker. Windows does not have native PThreads support. To add PThreads, you can link against libraries from the following project:

http://www.sourceware.org/pthreads-win32/

For a walkthrough on how to get it working in Code::Blocks, please consult this thread:

http://multicorebsp.com/forum/viewtopic.php?id=27

Offline

Board footer

Powered by FluxBB