-
Notifications
You must be signed in to change notification settings - Fork 470
foreign_library with c++ files does not add stdc++ dependency #4847
Copy link
Copy link
Closed
Description
Expected Behavior
Be able to compile an executable in bytecode while linking with a library containing c++ foreign_archive.
To do so, the ocamlmklib should be invoked with -lstdc++.
Dynamique section
$ readelf -d _build/default/lib/dllhello_world.so
Dynamic section at offset 0x2db0 contains 27 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x1000
0x000000000000000d (FINI) 0x11bc
0x0000000000000019 (INIT_ARRAY) 0x3d98
0x000000000000001b (INIT_ARRAYSZ) 16 (bytes)
0x000000000000001a (FINI_ARRAY) 0x3da8
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x2f0
0x0000000000000005 (STRTAB) 0x420
0x0000000000000006 (SYMTAB) 0x318
0x000000000000000a (STRSZ) 309 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x3fa0
0x0000000000000002 (PLTRELSZ) 72 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x6b0
0x0000000000000007 (RELA) 0x5c0
0x0000000000000008 (RELASZ) 240 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW
0x000000006ffffffe (VERNEED) 0x570
0x000000006fffffff (VERNEEDNUM) 2
0x000000006ffffff0 (VERSYM) 0x556
0x000000006ffffff9 (RELACOUNT) 4
0x0000000000000000 (NULL) 0x0
Actual Behavior
Dynamique section
$ readelf -d _build/default/lib/dllhello_world.so
Dynamic section at offset 0x2dc0 contains 26 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x1000
0x000000000000000d (FINI) 0x11bc
0x0000000000000019 (INIT_ARRAY) 0x3da8
0x000000000000001b (INIT_ARRAYSZ) 16 (bytes)
0x000000000000001a (FINI_ARRAY) 0x3db8
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x2f0
0x0000000000000005 (STRTAB) 0x420
0x0000000000000006 (SYMTAB) 0x318
0x000000000000000a (STRSZ) 268 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x3fa0
0x0000000000000002 (PLTRELSZ) 72 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x658
0x0000000000000007 (RELA) 0x568
0x0000000000000008 (RELASZ) 240 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000000000001e (FLAGS) BIND_NOW
0x000000006ffffffb (FLAGS_1) Flags: NOW
0x000000006ffffffe (VERNEED) 0x548
0x000000006fffffff (VERNEEDNUM) 1
0x000000006ffffff0 (VERSYM) 0x52c
0x000000006ffffff9 (RELACOUNT) 4
0x0000000000000000 (NULL) 0x0
$ dune build --root .
File "_none_", line 1:
Error: Error on dynamically loaded library: ./lib/dllhello_world.so: ./lib/dllhello_world.so: undefined symbol: _ZSt4cout
Reproduction
- PR with a reproducing test:
Specifications
- Version of
dune(output ofdune --version): 2.9 - Version of
ocaml(output ofocamlc --version): 4.08 - Operating system (distribution and version): ubuntu 20.04
Additional notes
- The
foreign_libraryshould supportlibrary_flagsandc_library_flagsin order to add other dependencies - Would be helpful to be able to create a
foreign_librarymixing c and c++ files (e.g.(languages c cxx))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels