This code works perfectly on a command line application in linux in the main() function. Creates the file next to the executable.
If I create a dynamic library with t