I am trying to write DLL files under the Digital Mars C/C++ compiler for use with Liberty BASIC, but I can't seem to get them to compile correctly. Can anyone help me with what I'm doing wrong?
I am trying to write DLL files under the Digital Mars C/C++ compiler for use with Liberty BASIC, but I can't seem to get them to compile correctly. Can anyone help me with what I'm doing wrong?
I don't really understand how you want the code placed in the window. I was confused by the instructions, so if you could offer a better explanation, that would help me greatly.
I get a ton of error messages, saying things like "Symbol Undefined." I can make DLLs with functions that don't use <stdio.h> or other headers, but when I try to include header files, it doesnt work right.Code:#include <ben.h> #include <stdio.h> unsigned int file_func(char dir[], char dir2[]) { FILE *fp, *fp2; fp = fopen(dir, "r"); fp2 = fopen(dir2, "w"); fclose(fp); fclose(fp2); return 0; }
here is my header code for <ben.h>:
Code:#ifndef BEN_H #define BEN_H 1 unsigned int file_func(char dir[], char dir2[]); #endif
You need to post the actual error messages.
I'll have to look at them. I'll have them posted sometime soon
this code actually works:
this code doesn't, and has these error messages:Code:#include <dlldemo.h> unsigned int foo(unsigned int i) { return i / 2; } unsigned int bar(unsigned int i) { return i / 3; }
Error 42: Symbol Undefined _GetCurrentThreadId@0Code:#include <dll.h> unsigned int filecopy(FILE *ipf, FILE *opf) { int c; while ((c = getc(ipf)) != EOF) putc(c, opf); }
Error 42: Symbol Undefined _CreateSemaphoreA@16
Error 42: Symbol Undefined _ReleaseSemaphore@12
and the list goes on. Any idea what Im doing wrong?
Make sure you have <stdio.h>, directly or indirectly.
What are you linking with? Why do you have <dll.h> instead of <dlldemo.h>?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
<dlldemo.h> was a library that I got from a website, and <dll.h> was a library of mine to prototype the function. Here is the code for both of them:
dlldemo.h:
dll.h:Code:#ifndef DLLDEMO_H #define DLLDEMO_H 1 unsigned int foo(unsigned int i); unsigned int bar(unsigned int i); #endif
My compiler does everything on its own. All I do is type "dmc dlldemo.c dlldemo.dll" and it compilesCode:#ifndef _DLL_H_ #define _DLL_H_ #include <stdio.h> unsigned int filecopy(FILE *ipf, FILE *opf); #endif
Other than the fact that you don't return a value and you don't include <stdio.h> (which is where FILE is defined), there's nothing wrong with this code. Nothing that should be producing linker errors. Try the code (with a void return value) in a separate program.Code:unsigned int filecopy(FILE *ipf, FILE *opf) { int c; while ((c = getc(ipf)) != EOF) putc(c, opf); }
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I've used this code before, and it always worked perfectly, but when I try to make it into a DLL file, I get those error messages. I dont understand what I'm doing wrong. Can you maybe explain how I'd go about making these into a DLL file? I just forgot that I changed the return type, so I'll cange it back.
also, my source file uses <dll.h>, which includes <stdio.h>
I'm getting 'Symbol Undefined' messages while linking
The FAQ: http://www.digitalmars.com/faq.htmlSymbol Undefined
A symbol remained undefined after all input files, including libraries, had been processed. Common causes for this are:
* A function was called in your code, but the function was never written.
* A virtual function was declared, but never written.
* A data variable was referenced, but never defined anywhere.
* Did not specify all the .obj files to the linker.
* The calling conventions of the function being referenced do not match the calling conventions of the defined function. Compiler switches, memory models, and special keywords can all affect calling convention (and thereby the name of the symbol as it appears in the .obj file).
* One or more missing library files (.lib). One way to figure out which .lib file contains the missing symbol is to run:
\dm\bin\grep symbolname \dm\lib\*.*
* The LIB environment variable is missing or not pointing to the \dm\lib directory or wherever the .lib files reside.
well, what i cant understand is why it allows me to make some DLLs, but not others. I'm not using any of the symbols or anything that it is saying... any idea as to why it compiles code that has no header files included, but not ones that do?
You need to link to kernel32.dll, and that should get rid of those errors. Read the digitalmars FAQ that Tonto linked to in his last post to figure out how to link to libraries. The import library name (assuming your compiler can link to import libraries) is kernel32.lib