@gibson, here's what seemed to work for me.
I changed `mylib.nim` to be like this, but I only did so to get rid of the
duplicate name:
import strutils, sequtils, os, parsecsv, streams, future
proc parseCSVListLine*(str: cstring): cstringArray {.exportc.} =
var ss = newStringStream($str)
var p: CsvParser
p.open(ss, "parseCSVListLine()")
discard p.readRow()
return allocCstringArray(lc[ col.strip() | (col <- items(p.row)), string])
Run
I changed the `main.cpp` as follows:
// main.cpp
#include <iostream>
#include "mylib.h"
using namespace std; // for demo
int main() {
NimMain(); // Need to add this for Nim's GC calls and other Nim related
things
parseCSVListLine("one,two,three");
return 0;
}
Run
And here's how I made it work using the latest Nim devel branch:
nim cpp --noMain --noLinking --header:mylib.h mylib.nim
Run
And to compile the c++ code:
g++ -I/home/joey/Nim/lib -I/home/joey/.cache/nim/mylib_d/ -o main main.cpp
~/.cache/nim/mylib_d/*.cpp -w
Run
note that in the above command, the `-I` calls are a bit finicky. You need to
specify the full path. Also I compiled on Ubuntu, so windows mileage may vary.
Let me know if this works for you.