FreeImage Problems
BlitzMax Forums/Brucey's Modules/FreeImage Problems
| ||
Hi again, I'm getting problems with Freeimage. I'm using TDM Mingw 4.7.1. The problem only occurs when I try to save a pixmap as a JPEG format, other formats work fine. The program crashes with Visual C++ runtime error: requested runtime to terminate in unusual way and then 'terminate called after throwing an instance of 'char const*' SuperStrict Framework brl.standardio Import bah.freeimage Local FreeImage:TFreeImage = LoadFreeImage("Banner.png") FreeImage.save("BannerSave.jpg", FIF_JPEG, 85) Where Banner.png is Does anyone else get this error or is it just me? |
| ||
The actual error is "FreeImage: only 24-bit highcolor or 8-bit greyscale/palette bitmaps can be saved as JPEG" You may need to convert it before saving. I'm not sure why it isn't catching the exception inside FreeImage though, as it is meant to. |
| ||
Tested on TDM 4.9.2, and it reported the error correctly. I'll have a go with 4.7 next. |
| ||
Rebuilt with TDM 4.7.1 and it crashes as you've described. Also rebuilt with TDM 4.8.1 and again it crashes - instead of internally catching the exception (this stuff is internal to FreeImage) So, it looks like you are better off with the latest TDM to handle this particular issue within FreeImage... |
| ||
Thanks Brucey, once again very helpful. On a side note what version of TDM would you recommend I use to compile all your Bah, Wxmax modules? |
| ||
All? I'd say 4.9.2 but there are known issues. I need to work on updating wxMax for 4.9.2 first, and then sort out the rest. 4.8.1 should generally see you fine though, the above FreeImage issue excepted. |
| ||
When I say All, I mean a select subset of your amazingly vast module collection :) Anyway the image conversion did the trick and fixed it. I've now moved onto trying to get my Mac environment setup and I'm having problems again lol. I've got 10.9 installed and working very well and I've installed Bmax 1.5 and when compiling it prompted me to install command line tools which I did. So now I can compile the sample programs fine and also compile all the modules fine using the default bmk. However when I tried to add your bmk_ng, I start getting problems. It compiles fine but after installing bmk, make.bmk and core.bmk to the bin folder, it no longer compiles any of the modules and crashes with 'fatal error: 'stdio.h' file not found #include <stdio.h>' Is it because I only have the command line tools installed and not xcode? I'm in the process of downloading xcode now but I'm not sure that will make a difference as it was working fine before adding your bmk_ng. Any ideas? |
| ||
**Bump** Installed xcode and it still has same problems as above. |
| ||
What result do you get when you run the following in Terminal? :xcode-select -p and perhaps also : gcc -v and from your BlitzMax/bin dir : ./bmk -v Thanks :-) |
| ||
Toms-Mac-Pro:~ tom$ xcode-select -p /Applications/Xcode.app/Contents/Developer Toms-Mac-Pro:~ tom$ gcc -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix Toms-Mac-Pro:bin tom$ ./bmk -v bmk 2.25 macos-x86 / clang 600.0.56 (cpu x2) Thanks |
| ||
stdio.h is a system include. The message suggests a configuration issue with your build tools, but if the original bmk is working... Can you try: ./bmk makemods -a -v brl.blitz -v here is verbose. It should dump out all the commands it is using. You may also wish to consider the latest bmk from here : https://github.com/bmx-ng/bmk (unlikely to fix the current problem, but it's capable of parallel builds of your code, which can often reduce compile times, depending on your code structure) |
| ||
I will most likely update to the newest bmk but I want to get a working configuration first :) Using bmk_ng: Toms-Mac-Pro:bin tom$ ./bmk makemods -a -v brl.blitz Compiling:blitz_app.c gcc -arch i386 -w -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.6.sdk -fno-exceptions -c -O2 -s -I/Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod -I/Users/tom/Documents/BlitzMax/mod -g -o /Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod/.bmx/blitz_app.c.debug.macos.x86.o /Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c In file included from /Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c:2: /Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod/blitz.h:5:10: fatal error: 'stdio.h' file not found #include <stdio.h> ^ 1 error generated. ~>Unhandled Exception:Build Error: failed to compile /Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c |
| ||
Using the built in bmk (working fine):Toms-Mac-Pro:bin tom$ ./bmk makemods -a -v brl.blitz Compiling:blitz_app.c gcc -I/Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod -I/Users/tom/Documents/BlitzMax/mod -w -arch i386 -mmacosx-version-min=10.4 -fno-exceptions -c -o /Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod/.bmx/blitz_app.c.debug.macos.x86.o /Users/tom/Documents/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c I'm guessing the line -isysroot /Developer/SDKs/MacOSX10.6.sdk is what is causing the issues as I do not have a /Developer folder (if I understand correctly it is now bundled in the xcode.app?). If it helps I'm using xcode 6.1.1 |
| ||
Well I sort of fixed it. I basically looked on my system for the standard stdio.h file and found one in "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/stdio.h" so I created a symbolic link from "/Developer/SDKs/MacOSX10.6.sdk" to "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/" and everything seems to be working correctly. Not sure why bmk_ng was looking for the 10.6 SDK though when I'm running 10.9.5 Thanks again Brucey for the help :) |
| ||
I've updated the latest source ( https://github.com/bmx-ng/bmk ) not to set sysroot, so it should now work as expected. Also tweaked the minimum osx version flag to be more consistent, and matched in both the compilation and linking sections. |
| ||
Everything seems to be compiling fine which is great. Although I do get trouble with your bah.libssl2 module (Only module that is causing problems):/Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:148:24: error: too many arguments provided to function-like macro invocation packet_size); ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:146:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:253:28: error: too many arguments provided to function-like macro invocation session->open_channel->remote.id, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:249:13: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:348:31: error: too many arguments provided to function-like macro invocation shost, sport, host, port); ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:346:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:428:24: error: too many arguments provided to function-like macro invocation port); ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:426:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:588:40: error: too many arguments provided to function-like macro invocation listener->host, listener->port); ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:586:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ [ 16%] Compiling:scp.c /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:737:33: error: too many arguments provided to function-like macro invocation varname, value, channel->local.id, channel->remote.id); ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:734:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:851:24: error: too many arguments provided to function-like macro invocation channel->remote.id); ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:849:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:964:13: error: too many arguments provided to function-like macro invocation channel->remote.id); ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:961:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:1056:43: error: too many arguments provided to function-like macro invocation channel->local.id, channel->remote.id, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:1053:9: error: use of undeclared identifier '_libssh2_debug' _libssh2_debug(session, LIBSSH2_DBG_CONN, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c:1184:33: error: too many arguments provided to function-like macro invocation request, channel->local.id, channel->remote.id, ^ /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/libssh2_priv.h:1019:9: note: macro '_libssh2_debug' defined here #define _libssh2_debug(x,y,z, __VA_ARGS__) do {} while (0) ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. Build Error: failed to compile (256) /Users/tom/Documents/BlitzMax/mod/bah.mod/libssh2.mod/src/channel.c On replacing the __VA_ARGS__ with ... in libssl2_priv.h, it compiled fine so not sure what is going on with that (guess my compiler/setup is slightly dodgy so its causing all these problems) |
| ||
Also with your latest bmk. I ran the following code:Framework BRL.FileSystem Import BRL.StandardIO Import BRL.Threads Import BRL.Max2D Import BRL.Freetypefont Import Bah.libcurlssl Import sidesign.minib3d Import Bah.libxml Import Bah.Regex Import BaH.Volumes Import PUB.FreeProcess Import Pub.FreeJoy Include "PathToEmptyFile" and get a linking error Building Test [ 99%] Processing:Test.bmx [ 99%] Converting:Test.bmx.console.release.mt.macos.x86.s [ 99%] Compiling:Test.bmx.console.release.mt.macos.x86.s [100%] Linking:Test.mt ld: file not found: clang: error: linker command failed with exit code 1 (use -v to see invocation) Build Error: Failed to link /Users/tom/Documents/Code/Test.mt Process complete Removing the include causes everything to work fine. |
| ||
I ran the following code... and get a linking error Thanks for the bug report :-) |
| ||
Interestingly, I cannot replicate that error. It always appears to compile successfully, even if "PathToEmptyFile" is zero bytes. I'd expect to see a filename after "ld: file not found: ", though... |
| ||
Interestingly if I use the old version of bmk_ng (the one with the -isysroot /Developer/SDKs/MacOSX10.6.sdk) it works perfectly fine (Obviously I do have to use a symbolic link tho). I get the linking error with the latest version of bmk_ng only if I use an 'Include' (file can be empty or blank or have content) which is very odd as surely the include should just insert the code into the file and shouldn't have anything to do with linking. Is there any more debug commands I can run to help you out? |
| ||
Ok I have done some sleuthing with a debug version of the bmk. The problem arrises as the ld.tmp file contains an empty line causing the linker to crash as it can't link a file that has empty filepath. This empty filepath arrises from the Include of a second file. More specifically it happens in bmk_modutil.bmx under the GetLinks method of TSourceFile. When it recursively gets to the Include file's TSourceFile, that TSourceFile has an obj_path="" which it add's to the linker list. This is the offending paragraph:If depsList And list Then For Local s:TSourceFile = EachIn depsList If Not modsOnly Or (modsOnly And s.modid) Then If Not stage Then If Not s.modid Then If Not list.Contains(s.obj_path) Then list.AddLast(s.obj_path) End If End If End If End If s.GetLinks(list, opts, modsOnly) Next End If I don't know entirely how bmk works (or how its supposed to work) so I can only suggest a solution which will work but might not be the correct one: putting a check to see if s.obj_path is empty string or if file exists before adding to list would solve this problem I'm having. |
| ||
ld.tmp was where I would be directing you next... Thanks for your detective work, Mister Holmes ;-) |
| ||
- wrong msg - |