Re: undefined reference to 'NewDouble'
- Posted by ghaberek (admin) Apr 21, 2013
- 1863 views
jimcbrown said...
I didn't think about this, but now that I think about it, there are actually like a gazillion things that the translator outputs in the translated C code that you'd need to mimic if you wanted to link it all by hand.
I'm starting to realize this! I had to pull out Argc, Argv, default_heap, and some strange object called _00. I thought that maybe this would be a better method compared to how Matt had imported a bunch of things manually from the Euphoria source (be.c, etc.). This may not be the proper method after all.
Although, we probably do need a better static library for working with Euphoria from an external library.
Regardless, here are my technically now-working sources, just for this test...
libtest.h said...
#ifndef _LIBTEST_H #define _LIBTEST_H #include <stdint.h> #include "euphoria.h" extern unsigned default_heap; extern object box_int( intptr_t x ); #endif // _LIBTEST_H
libtest.c said...
#include "libtest.h" int Argc; char **Argv; unsigned default_heap; struct routine_list _00[] = {}; object box_int( intptr_t x ) { if(x > NOVALUE && x < MAXINT) return (object)x; else return (object)NewDouble((double)x); }
test.c said...
#include "windows.h" #include "libtest.h" int main() { default_heap = (unsigned)GetProcessHeap(); object test1 = box_int( 1 ); // a simple int object test2 = box_int( MAXINT + 1 ); // should be a double return 0; }
Makefile said...
EUDIR = C:\Euphoria EUBUILD = $(EUDIR)\source\build BACKEND = $(EUBUILD)\libobj\back all: libtest.dll test.exe test.exe: test.o gcc -o test.exe test.o -L. -ltest test.o: test.c gcc -c test.c -o test.o -I. -I$(EUDIR)\include libtest.dll: libtest.o gcc -shared -o libtest.dll $(BACKEND)\be_alloc.o $(EUBUILD)\eu.a libtest.o libtest.o: libtest.c gcc -c libtest.c -o libtest.o -I$(EUDIR)\include .PHONY: clean clean: -@rm -f libtest.dll libtest.o test.exe test.o
-Greg