Clion unistd.h doesn't recognize fork() & getppid() - fork

When writing this simple code with fork() and getppid() aren't resolved by the IDE
I've Windows 11
My Clion version is 3.15
CMakeLists is CMAKE_C_STANDARD 99
Thanks for your time.
Attachments

Related

Is it possible to integrate nvcc with gcc/g++ in windows?

I would linke to know if it is possible to use gcc/g++ as the c/c++ compiler in windows based CUDA? Furthermore, how can I compile fortran together with nvcc?
I am running CUDA 10.2 and the mingw gcc 8.1.0.
No it is not possible. The only supported host compiler for use with CUDA on windows is cl.exe, the compiler that ships with visual studio C++.
If you use the WSL2 environment on windows, then you can use gcc/g++ with CUDA in that linux-like environment.

Compile Lua script to 32 bit bytecode on MacOS

I am compiling a Lua script into a binary on MacOS Catalina.
luac -s -o bin/my-binary.luac src/my-code.lua"
However, the application consuming the compiled script runs a 32-bit version of Lua and can't read the bytecode of the 64-bit compiled Lua script. (Error message: bad header in precompiled chunk).
Can I somehow (cross)compile the Lua script on current MacOS to a 32-bit binary?
My alternative would be doing the compilation with Docker but maybe there is an even simpler approach.
I don't see any option for cross-compilation or changing the bitness, but you may be able to tweak the Lua code to produce the code you need. Here is the maillist thread for Lua 5.1 that recommends using #define LUAC_STR_SIZE_TYPE int.
If this doesn't work, you may be able to change ldump.c to produce 32-bit compatible code. The source code has the following comment (5.4): All high-level dumps go through dumpVector; you can change it to change the endianness of the result. You may be able to update it to change bitness by changing handling of DIBS, dumpSize, and several other places.

MATLAB mex not looking for compiler gfortran on macOS

I need to call some Fortran code from within MATLAB. I did some research and read about the mex command and how to use it. Sadly I'm already failing at getting the Fortran compiler to work.
First of all, here's my setup:
macOS Sierra 10.12.1 (latest version)
MATLAB R2016b (latest version)
gfortran 4.9.2 (installed via .dmg from official GNU site)
According to the MATLAB documentation, I can use mex -setup FORTRAN to prepare mex for building a mex-file from Fortran. However, running the command in verbose mode yields the following output: mex -setup -v FORTRAN
Verbose mode is on.
... Looking for compiler 'Intel Fortran Composer XE' ...
... Looking for environment variable 'IFORT_COMPILER16' ...No.
... Looking for environment variable 'IFORT_COMPILER15' ...No.
... Looking for environment variable 'IFORT_COMPILER14' ...No.
... Looking for environment variable 'IFORT_COMPILER13' ...No.
... Executing command 'which ifort' ...No.
Did not find installed compiler 'Intel Fortran Composer XE'.
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2016b/maci64.html.
Following the link, one can see that MATLAB does support GNU gfortran 4.9.x on Linux. On Mac however, only Intel's commercial compilers are listed as supported. That's what mex seems to be looking for as well.
Since Mac can also use gfortran to compile Fortran code I thought it'd be possible to get it to work with MATLAB. I've also googled alot and found questions like this one on the MathWorks forum, which suggests that MATLAB should be able to use gfortran, even on Mac.
That's what I think is strange, my MATLAB isn't even looking for a gfortran compiler. All it does is look for an Intel compiler, can't find one and then throws above stated error message.
Regarding my gfortran installation. It is definitely 4.9.2 (which is listed as supported under Linux), which gfortran returns /usr/local/bin and I can successfully compile programs via Terminal.
By the way, mex -setup ANY successfully lists the compilers for C and C++ but no Fortran.
MEX configured to use 'Xcode with Clang' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
MEX configured to use 'Xcode Clang++' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the
new API. You can find more information about this at:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different C compiler, select one from the following:
Xcode with Clang mex -setup:'/Users/Lennart/Library/Application Support/MathWorks/MATLAB/R2016b/mex_C_maci64.xml' C
Xcode Clang++ mex -setup:'/Users/Lennart/Library/Application Support/MathWorks/MATLAB/R2016b/mex_C++_maci64.xml'
I also had a look at those .xml files mentioned at the very end of the last output. There was no file for anything having to do with Fortran and I wasn't able to successfully write one myself. I'm not even sure whether that's the problem...
So simply put my question is: How can I get MATLAB to actually look for and then of course also find my gfortran compiler to use it to compile mex files?
Appreciate your help!
Thanks to hsuyaa and the provided link I was able to resolve my problem. As it needed some more experimenting by myself, I'd like to post how exactly I was able to get gfortran to work.
Look at this link and the accepted answer. Although the MathWorks Team explicitly states that the instructions are specifically written for xCode 7.0 and MATLAB R2015b, I got everything to work with xCode 8.1, MATLAB R2016b and macOS Sierra 10.12.
MATLAB seems to be storing the compiler configuration details in .xml-files as mentioned before. You can find the directory in MATLAB by entering
cd( fullfile( matlabroot, 'bin', 'maci64', 'mexopts' ) );
I did perform a fresh install of MATLAB before but at that location, only three files where located, one for Clang, one for Clang++, one for Intel's Fortran. The gfortran one was simply missing.
The solution author at MathWorks appended all of these .xml-files to his post. I downloaded the files and copied gfortran.xml to the above mentioned folder. This granted partial success in that it made MATLAB actually look for gfortran when running the mex setup.
However, since the files are not up-to-date, I had to add a few lines. I don't exactly understand how the configuration files work, but I noticed that some lines where referring to older macOS versions. Download the file gfortran.xml behind the above link and then add the following:
Wherever you see
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk" />
or
<cmdReturns name="find $$ -name MacOSX10.11.sdk" />
also add
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk" />
or
<cmdReturns name="find $$ -name MacOSX10.12.sdk" />
macOS 10.12 is Sierra. Saving the file and running mex -setup FORTRAN again successfully identified gfortran and set it as the fortran compiler for mex.
Your matlab version is not able to detect the supported compilers. May be this Link can help.

Unable to run Qt debugger on Mac OSX

Trying to debug an application written in Qt on mac (10.6.8). Qt 4.8.6, QtCreator 3.2.0, I set up the debugger System GDB at /usr/bin/gdb and compiler gcc-4.2
I want to debug the code...
I get in the application output window
Debugging starts
Debugging has failed
Debugging has finished
(and no breakpoints were hit, nothing has started in code)
I opened the debug log window, and the only suspicious things I saw were
....
111^error,msg="Undefined command: \"python\". Try \"help\*.*
NOTE: ENGINE SETUP FAILED
State Changed From EngineSetupRequested(1) to EngineSetupFailed(2)
HANDLE RUNCONTROL FINISHED
.....
On the left, some of the commands had
109-interpreter-exec console "python sys.path.insert(1, "/Volumes/QtCreator/..."
110-interpreter-exec console "python sys.path.append("/usr/bin/data-directory/ python)"
111-interpreter-exec console "python from gdbbridge import *"
I checked that python is installed... i can type python from anywhere and get its command prompt so it is on system path...
I read something about having to sign a fsf debugger but the one I am using is not a fsf debugger ?
What can I do to debug my apps in macx ?
Edit: Tried gdb from command line, with the app as argument
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011)
...
This GDB was configured as "x86_64-apple-darwin"...
warning: Unable to read symbols for QtSvg.framework/Versions/4/QtSvg (file not found).
warning: Unable to read symbols from "QtSvg" (not yet mapped into memory).
warning: Unable to read symbols for QtGui.framework/Versions/4/QtGui (file not found).
warning: Unable to read symbols from "QtGui" (not yet mapped into memory).
warning: Unable to read symbols for QtCore.framework/Versions/4/QtCore (file not found).
warning: Unable to read symbols from "QtCore" (not yet mapped into memory).
warning: Unable to read symbols for QtNetwork.framework/Versions/4/QtNetwork (file not found).
warning: Unable to read symbols from "QtNetwork" (not yet mapped into memory).
Reading symbols for shared libraries .
... some warnings that .o is more recent than .dylib in dependent libs... but that I don't have to step into so I don't care...
...
warning: Could not find object file "/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64/crt3.o" - no debug information available for "darwin-crt3.c".
.... done
So I type run
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00007fff83872c00 in strlen ()
I don't know where that is (I do but really can't see it) or if it is an actual string pointer or something else...
I don't know where the breakpoints would be, the entire source is very long and contains lots and lots of files so I really don't know how I can do it with gdb from command line...
But it seems that it did get started, without complains about python ?
The warnings at start - could that mean that there is still hope, that it is possible to somehow configure gdb to run with Qt if it learns about its libraries ?
By the way... searching for the missing libraries...
QT 4.8.4 debug libraries not found on Mac OSX
I have tried to replace my debugger (in Qt) using lldb and qmake - in both cases I got an error "Unable to create a debugger engine of the type 'No engine'"
Edit: Another suggestion I read about is to recompile Qt Creator Binaries to add debug symbols... I hope that is not what I have to do because
"Note: With Qt Creator 3.2 we drop support for OS X 10.6 (Snow Leopard). The technical reason for this is that Apple does not support any kind of C++11 on that OS version. Of course that does not affect on which platforms you can run your Qt applications on. But it is not possible to run the Qt Creator 3.2 binaries on 10.6, and it also is not possible to compile Qt Creator 3.2 on 10.6 with the tool chains provided by Apple." (from release notes)
Update: I was able to find the cause of the error above (the KERN_INVALID_ADDRESS) by placing a zillion qDebug() statements... Though that was not what I am trying to accomplish, one error out of many.
I still have lots of errors... Attaching a debugger would be wonderful. I have listed the required libs for the program - they seem to exist. Not sure if they are "debug" or "release" libraries. .... But I am not trying to step through the Qt sources, so why would it matter if I have debug symbols for them ? And if they were "release" type libs, then my whole program, build in "debug", would not execute or even fail to build ? Since I am building my code in "Debug" mode and it executes, the libraries must be correct, right ?
So confusing...
QtCreator 3.2 (and a few versions before that) requires a GDB that has Python scripting enabled (or LLDB, or CDB on Windows). On Mac, Apple's GDB doesn't have Python scripting, and therefore cannot be use with Qt Creator. FSF GDB works for some projects on Mac, but in general LLDB is preferable there.
Your "GNU gdb 6.3.50-20050815 (Apple version gdb-1518)" is such an non-Python-enabled Apple build.

has anyone successfully built qt 5.0.0 from source on windows 32-bit, on mysis, using mingw 4.72?

I have been programming in c++ for sometime now, but mainly console programs. i have learnt several data structures, pointers and i'm sure i'm capable of developing some simple software. so i decided to download qt and start learning how to create UIs, but the problem is that i have mingw 4.72 and qt 5.0 complained that it only works with win32API version 3.13 while my mingw installation has 3.17. so i decided to build qt 5.0.0 from source using the mingw 4.72,, but i'm getting compiler errors such as this
c:/qt-everywhere-opensource-src-5.0.0/qtbase/qmake/library/qmakeevaluator.cpp: in
member function 'void QMakeEvaluator::loadDefaults()':
c:/qt-everywhere-opensource-src-5.0.0/qtbase/qmake/library/qmakeevaluator.cpp:968:43:
error: cannot convert 'wchar_t*' to 'LPSTR {aka char*}' for argument '1' to 'BOOL
GetComputerNameA(LPSTR, PDWORD)'
make.exe: *** [qmakeevaluator.o] Error 1 *** qtbase/configure exited with non-zero
status..
so my question is this, has anybody successfully built a stable qt 5.0 for 32-bit windows 7, using mingw 4.72? i have all the prerequisites, perl, ruby and python....
i decided to go with version 4.8.4, and the configuring has gone smoothly. yet to to type mingw-make since i have been told it takes a while to finish. there is a good guide here http://wiki.batcom-it.net/index.php?title=Building_Qt_on_Windows_%28MinGW%29. i hope it helps someone...

Resources