|
From: David T. <dtu...@st...> - 2009-07-31 03:46:06
|
I am trying to build a program using the proj.4 library on MinGW/WinXP. The program runs fine in the MinGW shell. When run outside MinGW, floating point values come back from a function as 1#.IND (undefined, NaN) and the printfs I added to the function are not run. This seems to depend on whether I run the program from the directory it was compiled in. The program produces valid xy values -- but still does not run the gn_sinu printfs -- if I run it from inside the directory where it was compiled. It fails if I run it from a copy of that directory, which makes no sense to me. It fails if the current working directory is not the compilation directory. MinGW bash runs it without problems in all these cases. Brief overview of how proj works: Each projection is a separate .c file that becomes a separate .o file in the libproj.a library. Each .c file has macros FORWARD and INVERSE that are expanded to functions. I am using the "goode" forward function which in turn calls the "sinu" forward function, which returns a struct of doubles which are coming back as undefined NaNs. My full compile line: g++ -g --static -DPROJ4 -g libdbf.c shapestuff.cc shpopen.o dbfopen.o shpgeo.o libproj_dmt.a -o ../appoint_part1.cgi All the other files should not matter. -DPROJ4 does not matter either by this point; I needed it earlier for the shpgeo file. Everything was compiled in MinGW on the same machine. Example output from MinGW bash: $ ../appoint_part1.cgi In forward, sinu 414d10 moll 41f120 reg 6, lam0 0.0000, l,p are: -0.9974, +-0.5407 DEBUG: gn_sinu P->m 0 lam +13444353561806976000000000000000000000000000000000000.0000,-6696286104189131600 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000.0000 DEBUG: gn_sinu post returning xy 0.0427,-0.5407 In forward after mods lam0 0.0000, x,y are: 0.0427, -0.5407 lp is 0.0497, +-0.5407 In inverse, reg 6, x,y are: -1.0046, -0.5407 In inverse after mods lam0 0.0000, x,y are: 0.0426, -0.5407 lp is 0.0497, +-0.5407 Example output from Windows cmd: >appoint_part1.exe In forward, sinu 3e2758 moll 3e2878 reg 6, lam0 0.0000, l,p are: -0.9974, +-0.5407 In forward after mods lam0 0.0000, x,y are: -1.#IND, -1.#IND lp is 0.0497, +-0.5407 (The program then hangs here because it goes into a loop comparing against the NaN value and I am a bad programmer who forgot to check for that.) Example output from the compilation directory: >..\appoint_part1.cgi In forward, sinu 414c50 moll 41f270 reg 6, lam0 0.0000, l,p are: -0.9974, +-0.5407 In forward after mods lam0 0.0000, x,y are: 0.0427, -0.5407 lp is 0.0497, +-0.5407 In inverse, reg 6, x,y are: -1.0046, -0.5407 In inverse after mods lam0 0.0000, x,y are: 0.0426, -0.5407 lp is 0.0497, +-0.5407 All printfs here go to stderr, in case that matters as to why the gn_sinu printfs are not appearing when run from cmd. The file extension (exe or cgi) has no effect on the program's behaviour. What might cause the struct to come back full of NaNs? Why would the working directory matter? Why would it matter whether I am in bash or cmd? Why aren't the gn_sinu printfs showing up even when it appears the function is run successfully? Thanks in advance for any help, - David T. |