[PROJ] Linking proj as a static lib to a Windows application

Finn Arildsen finn at arildsen.com
Wed Apr 8 08:35:00 PDT 2020


Hi,

 

I'm working on integrating PROJ into my Windows application, and I have a
problem with uninitialzed static variables in the PROJ lib.

 

So far I have been able to build the PROJ lib using the supplied CMAKE
scripts.  I have successfully linked the lib to my application, and I have
been able to call library functions.  proj_context_create connects to the
sqlite database correctly etc.   

 

However, the static objects in the PROJ library are never initialized -
constructors are never called, so eventually the library crashes in a call
to  UnitOfMeasure::conversionToSI, because UnitOfMeasure::DEGREE is not
initialized.

 

I have successfully run the library test suite, and I can see that when
running the test programs in the debugger, the library static constructors
get correctly called from the run-time library's _initterm function (through
a list of function pointers, which I assume the linker sets up).   

 

When running my own application, the _initterm function is also correctly
called, but it never calls the PROJ static constructors.   

 

I use Visual Studio 2019, and I have carefully checked and compared compiler
and linker options between the test suite and my application and have not
found anything that can explain this.

 

I wonder if any of the people who have contributed the test suite may have
any ideas as to why this happens?

 

Thanks in advance for any help.

 

Finn Arildsen

Denmark

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20200408/9cdd6ebe/attachment.html>


More information about the PROJ mailing list