digitalmars.D.learn - ImportC: unresolved external symbol
- ryuukk_ (29/29) Jun 14 2022 Hello
- Mike Parker (10/17) Jun 14 2022 This works from the command line:
- ryuukk_ (8/24) Jun 14 2022 That was the issue!
Hello Tried to give ImportC a try to finally get rid of gluecode in one of my project, but this simple test gives me a compile error: nk.c ``` int test(void) { return 1; } ``` app.d ``` import std.stdio; import nk = nk; void main() { if (nk.test() != 0) { writeln("test"); } } ``` ``` nk.obj : error LNK2019: unresolved external symbol test referenced in function _Dmain ``` Am i missing something important? (that is a dub project, created with: dub init) DMD: v2.100.0-dirty
Jun 14 2022
On Tuesday, 14 June 2022 at 14:32:50 UTC, ryuukk_ wrote:``` nk.obj : error LNK2019: unresolved external symbol test referenced in function _Dmain ``` Am i missing something important? (that is a dub project, created with: dub init) DMD: v2.100.0-dirtyThis works from the command line: ``` dmd -m64 app.d nk.c ``` It's possible dub isn't passing the C file to the compiler. Assuming everything's configured properly (e.g., both files are in the same source directory, or the paths are properly set if they aren't), you should do a verbose build and see what the compiler command line looks like.
Jun 14 2022
On Tuesday, 14 June 2022 at 14:38:17 UTC, Mike Parker wrote:On Tuesday, 14 June 2022 at 14:32:50 UTC, ryuukk_ wrote:That was the issue! Adding the file manually in the dub.json solved it! ``` "sourceFiles": [ "source/nk.c" ] ``` That should be easy to fix, i'll fill a PR Thanks``` nk.obj : error LNK2019: unresolved external symbol test referenced in function _Dmain ``` Am i missing something important? (that is a dub project, created with: dub init) DMD: v2.100.0-dirtyThis works from the command line: ``` dmd -m64 app.d nk.c ``` It's possible dub isn't passing the C file to the compiler.
Jun 14 2022