Skip to content

Instantly share code, notes, and snippets.

@nigredo-tori
Last active September 15, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nigredo-tori/9f774894c38f7a6a607270a6a456ea20 to your computer and use it in GitHub Desktop.
Save nigredo-tori/9f774894c38f7a6a607270a6a456ea20 to your computer and use it in GitHub Desktop.
Problem with dynamic library (Linux)
#include "foo.h"
int main(int argc, char** argv) {
foo();
}
import logging
# Uncommenting this circumvents the problem
# {.emit:"""
# int cmdCount;
# const char* cmdLine[0];
# """.}
proc foo*() {.exportc, dynlib, cdecl.} =
echo "in foo"
set -e
nim c --app:lib --header --forceBuild --passC:-fPIC foo.nim
gcc -o bar -L . -I nimcache -I ~/work/nim/lib bar.c -l foo
LD_LIBRARY_PATH=. ./bar
./libfoo.so: undefined reference to `cmdCount'
./libfoo.so: undefined reference to `cmdLine'
collect2: error: ld returned 1 exit status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment