Blide Import C file undefined reference
BlitzMax Forums/BlitzMax Programming/Blide Import C file undefined reference
| ||
Hi When I'm importing this in a New Temporal BMX file SuperStrict Framework BRL.StandardIO Import "Math.c" Extern Function PowerOf:Float(X:Float, Y:Float) End Extern Local X:Float = 4.0, Y:Float = 2.0 Print PowerOf(X, Y) It's working But when I import third party code on my managed blide solution I get this error : C:/BlitzMax/lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16' This is my Math.c file #include <math.h> float PowerOf(float base, float exp) { return pow(base,exp); } As you can see I'm trying to use Math C function but this error give me problem. What's this error and how to remove it ? Thanks |
| ||
Possibly you need to use doubles. |
| ||
It's true But this not fix the problem :s |
| ||
Typically, you'll get that error if you are trying to build a C file and then execute it. I don't use Blide so I am unsure of how its project settings work but make sure that it is compiling and executing the BlitzMax source file. |
| ||
The error implies BlitzMax has not imported the AppStub correctly - containing a main() function. (as in the main() which all applications require). |
| ||
Disable quick build and let me know if that fixed it. If this is not the case, please send me a small solution replicating the issue in order for me to check if BLIde is doing something it should not. EDIT: Be sure to not be trying to execute the C file directly, as it'll requiere a starting point. BLIde and BMK can compile C and C++ files, so it seems you're trying to create a EXE based on your C file, instead of based on the solution that imports the C file. |
| ||
confirmed, that's the error you get on MinGW when trying to build a C file without a main procedure: C:/Program Files/BlitzMax/lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16' Be sure to be executing the solution and not the imported C file as a stand-alone file. |
| ||
I'm sorry but I don't quite get it. I understand that mingw is searching for an entry point but I just want to import a set of functions coded in C. Would it be possible to produce a small example on how to achieve this ? I mean in a Blide Solution since unmanaged work fine... I've put a small Blide solution with import of C code to work on here : http://arm42.free.fr/files/blideSolutionImportC.zip Thanks ! |
| ||
@Armitage1982: This can be easilly solved. If you open the dependencies tree of your solution, you'll see that you have a root node for math.c, so BLIde thinks you're using this C file to create a EXE. Remove the root node and leave only the import. To do so, open the project dependencies tree (Alt+2). Right click over the Math.c root node there and select "Project Manager". Then a dialog will open showing all EXEs or MODs being built by the solution. Select the Matc.c and click on Remove Program. (you'll be prompted to accept and refresh the solution). Then, you're done! When you do this, you'll see the file Math.c does not appear on the solution tree. That's expected as C files are not Managed by blide. You can access the file still using the local shortcuts window, or the project dependencies tree. It seems that when you add a unmanaged program written in C, blide automatically adds ALSO a EXE build mode for the node. This will be changed in the future! |
| ||
Working ! Thanks a lot Ziggy, this is an advanced feature of Blide that I wasn't aware of. I never use the Dependencies tree before. My C program work great now :) |