`NimMain` not exported in DLL, but `NimMainInner` is #4840

Closed
euantorano opened this Issue Sep 30, 2016 · 0 comments

Projects

None yet

1 participant

@euantorano
Contributor
euantorano commented Sep 30, 2016 edited

I'm testing accessing a DLL created using Nim inside another program. I created a very simple Nim module:

proc addTwoInts*(a, b: cint): cint {.cdecl, exportc, dynlib.} =
  ## addTwoInts adds two integers together.
  result = a + b

I then compile it with:

nim c -d:release --header --app:lib --noMain adder.nim

This creates an adder.dll file as expected, and adds a header adder.h to the nimcache directory:

/* Generated by Nim Compiler v0.14.2 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Windows, amd64, gcc */
/* Command for C compiler:
   gcc.exe -c  -w -O3 -fno-strict-aliasing  -IC:\Nim\lib -o c:\users\euan\desktop\nimadder\nim\nimcache\adder.o c:\users\euan\desktop\nimadder\nim\nimcache\adder.h */
#ifndef __adder__
#define __adder__
#define NIM_INTBITS 64

#include "nimbase.h"
N_NOCONV(void, signalHandler)(int sign0);
N_NIMCALL(NI, getRefcount)(void* p0);
N_LIB_IMPORT N_CDECL(int, addTwoInts)(int a0, int b0);
N_LIB_IMPORT N_CDECL(void, NimMain)(void);
#endif /* __adder__ */

However, if I look at the generated DLL using DLL Export Viewer I see two functions exported:

  • addTwoInts (my exported function)
  • NimMainInner

The documentation says that a function NimMain should be exported and should be called at the start of the program in order to initialise Nim's internals but obviously this isn't possible.

I've included a screenshot of the export viewer display below.

v2lfqzw

@Araq Araq pushed a commit that closed this issue Oct 3, 2016
@jangko jangko fixes #4840 c0470ed
@Araq Araq closed this in c0470ed Oct 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment