Compiling SDL within Adobe Crossbridge's Cygwin - c++

Crossbridge allows you to compile C/C++ programs to target the flash runtime. It comes with its own modified gcc within cygwin. Since SDL only provides developmental zips for VC or mingw, I'm trying to compile SDL within this cygwin environment. However Crossbridge's gcc is version 4.2.1 and according to google searches SDL cannot be compiled with gcc versions higher than 3 inside cygwin. When I run ./configure, it fails with:
*** Your compiler (/cygdrive/c/Users/Tom/Desktop/Crossbridge_1.0.1/sdk/usr/bin/g
cc.exe -jvmopt=-Xmx1G) does not produce Win32 executables!
When I just type gcc alone, I get:
bash: /usr/bin/gcc: cannot execute binary file
Does it make a difference if I compile SDL using one compiler (i.e., a lower version of gcc) and attempt to use it with the Crossbridge compiler?
Is there a workaround for this?

I checked the Crossbridge_1.0.1.zip, cc and gcc maybe are broken link (only 56 bytes?) but the gcc-4 seem to be good.
edit
type gcc-4 as you typed gcc from the bash and you'll see the usual expected no input files gcc's error message, try gcc-4 -v
the message Your compiler does not produce Win32 executables is given by the fact that whatever you've executed (or has been executed automatically) is using /cygdrive/c/Users/Tom/Desktop/Crossbridge_1.0.1/sdk/usr/bin/gcc.exe as your compiler, but as you already checked it doesn't work, and if you check it with ls -l /usr/bin/gcc.exe you'll see that this is only 56 bytes size, this can't be the real compiler, I guess it probably was a symbolic link to the real compiler, which for some reason isn't working as expected (on linux executing a symlink is as executing the real binary).
I'm not an expert of cygwin, but I guess at some level symlink are supported, reading this FAQ make me wonder if some attribute hasn't lost packaging/unpackaging the zip, so that the symlink aren't recognized.
Try to recreate it (it worked for me):
cd /usr/bin # change directory
rm gcc.exe # remove the broken link
ln -s gcc-4.exe gcc.exe # re-create the symlink
run gcc again, should return the no input files error as expected.
But this isn't the solution, because probably in the unzipped files there are many broken symlink.
I can't believe Adobe is distributing a broken SDK, so perhaps there's some instruction somewhere about how to properly unzip the SDK preserving the symlinks (maybe unzip have a preserve attribute option? I don't know much about zip sorry.
edit
execute the run.bat (the bash) and cd to the main directory where you unzipped the SDK (mine is /cygdrive/c/crossbrige)
cd /cygdrive/c/crossbrige
for f in $(find ./ -type f -print0 | xargs -0 grep '!<symlink>' -l); do attrib +S $f; done
this should hopefully fix all the broken symlink, the only side-effect is that any file containing !<symlink> will get set the attribute DOS SYSTEM, but cygwin check both this magic string at offset 0 and the S attribute to consider a file as a symlink, so hopefully will not break anything.

I used Alex find/ attribute loop to fix all broken links in my cygwin install. I have no idea why they appeared.
The first attempt failed with messages like:
Invalid switch - /usr/lib/terminfo
for each file attrib worked on.
Turned out that for my cygwin/Windows combo I had to cd into the directory and execute attrib from there. So the loop content was:
do cd $(dirname $f); attrib +S $(basename $f); done

Related

How to use untwister?

https://github.com/altf4/untwister
I wanted to use the above program to predict some PRNG. I have read the 'usage' part, I though I should use it in cmd.exe by entering the path of the untwister. I entered the path of main.cpp, only MSVC pops up. Also, MSVC doesn't allow me to debug/compile the file, so I cannot run it. I searched 'how to use untwister' on google, but there is no further instruction. I am a beginner of programming, please forgive my ignorance.
OK, based on #drescherjm comment's, I've successfully build it.
I installed msys2 and use mingw to build it. But the .exe file has
error "_zst28__throw_bad_array_new_lengthv"
I searched the error message on google, and discover that the problem
may caused by gcc version.
I downloaded an old version (10.3.0) of gcc and mingw here:
https://winlibs.com/
I typed "cd /d D:\abc" then "mingw64\bin\mingw32-make.exe" in cmd, it
showed "Nothing to be done for" error.
I discover that I can use option to force the mingw32-make.exe to
read the Makefile. I added .am to the filename of Makefile, then type
mingw64\bin\mingw32-make.exe -f D:\abc\untwister-master\Makefile.am
The mingw32-make.exe thinks that files in
D:\abc\untwister-master\prng are in D:\abc\prng, and tells me it
can't find the files.
I moved all files and folder to D:\abc, then success!

How can I specify the location of one file for program configuration without specifying the location for all C compilers in Unix?

I am trying to compile a program called Clustal Omega on my Unix operating system. I do not have root access. Clustal Omega requires argtable2 to compile. I installed argtable2 in my home/user/bin/ and the Clustal Omega installation instructions suggest I use:
./configure CFLAGS='~/bin/argtable2-13/include'
Which specifies the location of the argtable2.h file.
However, when I run this I get an error because it tries to retrieve gcc and g++ C compilers from that location as well, when actually they are in the root/bin/ which I cannot edit.
I've tried:
./configure CC='/opt/apps/gcc/6.3.0/bin/gcc' CXX='/opt/apps/gcc/6.3.0/bin/g++' CFLAGS='~/bin/argtable2-13/include'
and
./configure CFLAGS='~/bin/argtable2-13/include' LDFLAGS='~/bin/argtable2-13/lib'
which was suggested elsewhere. Neither are able to complete configuration.
How can I specify the location of the argtable2-13 required files without specifying the location of all the C compilers?
Thanks, everyone, but the following did not work either:
./configure CPPFLAGS='~/bin/argtable2-13/include'
./configure --with-argtable2.h='~/bin/argtable2-13/include'
./configure --with-argtable2='~/bin/argtable2-13/include'
./configure CFLAGS='-I ~/bin/argtable2-13/include'
Not sure if this is the right thing to put in but I don't know which program to request --help from?
The error is:
checking argtable2.h presence... no
checking for argtable2.h... no
configure: error: Could not find argtable2.h. Try $ ./configure CFLAGS='-Iyour-argtable2-include-path
There are two main issues:
CFLAGS needs to be the flags you want to add (not just the directory). Similarly for LDFLAGS.
Shell expansions (tilda prefix in this case) are not performed on the strings passed to configure. Use expanded path.
Combining that the configure command should be:
./configure CFLAGS="-I /home/<username>/bin/include" LDFLAGS="-L /home/<username>/bin/lib"

Can GCC compile and run a source code without generating object or executable files?

Can GCC compile and run a source code without generating any output file (neither object nor executable), in a manner that is supported cross-platform? Especially, a solution supported by GCC directly.
I want to avoid generation of any trace file since that is a minor code in a big project. It just messes up the bin directory.
An existing question, here, provides a solution for compiling source code without generating any output file, such as:
gcc somefile.c -o /dev/null
However, this only compiles, and doesn't run.
Another similar question here provides a solution that is specific to Windows OS, not cross-platform.
A simple bash script might help:
#!/bin/bash
echo 'compile... ' $1
gcc $1 && ./a.out && rm a.out
supposed it's named once, then you can do
$ sh once any.c
to compile any.c and just run it once.
You can also make once executable with chmod +x once so you can just type
$ once any.c
Hope it helps ;)
In order to compile and run the C / C++ program and then remove the compiled file, you should add a function to delete the program after it is executed.
Here is a link to an example of a program that deletes itself.
Click Here
In your case (you want to avoid cluttering the build tree), a practically useful solution might be to have some convention about temporary executables.
For example, you could decide that every intermediate executable or file is named *.tmp or _* or *.tmpbin (for temporary binaries) and have some Makefile rules which removes them. Or you could use mktemp(1) in your Makefile to get a temporary file name. Don't forget to remove it later.
Also, most big projects have a compilation step and an installing step (often make install); and if you don't have that you probably should. You want your installing step to avoid installing the temporary binaries or files; with some naming convention this is quite simple: the first command for install phony target in your Makefile would remove these temporary binaries or files.
Also, you generally build in a file tree different of the final bin/ directory, so you could leave the temporary executables in the build tree.
As several people noticed, removing its own executable is easy on Linux (do a readlink(2) on "/proc/self/exe" (see proc(5) for details) then unlink(2) the result of readlink....) but difficult on Windows.
So practically your question is not a very important issue.... (if you use suitable build conventions). And GCC work on files (because it will run ld internally to build that executable file); however GCCJIT is hiding them. AFAIK, you won't even be able to use /dev/stdout as the executable output of gcc (but you can run gcc -x c /dev/stdin to compile C code from stdin). So GCC cannot avoid making an executable file (but you could have it temporary, or in a tmpfs file system or a FUSE one). So you need something external to your gcc command (perhaps simple an rm in some following line of your Makefile) to remove the produced executable.
You could also decide to have (dynamically loaded) plugins (e.g. use dlopen(3) on Linux). Your main program could load a plugin (with  dlopen on Linux) - perhaps even after having generated dynamically its C++ code and having compiled that generated code into e.g. some shared object .so on Linux (or some DLL on Windows), as I do in MELT -, run functions in it obtained with dlsym, and unload the plugin (with dlclose on Linux) and finally remove it. You might use cross-platform frameworks like Qt or POCO to avoid dealing with OS specific plugin code.
For c gcc/g++ filname.c && ./a.out && rm a.out
For c++ g++ filename.cpp && ./a.out && rm a.out

Building log4cxx with APR

I need to build the log4cxx library on a SuSE linux system where I am not root. The package manager, zypper, apparently does not know about log4cxx.
I download log4cxx and try to build with autotools
./configure
checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.
I then search for libapr:
find / -name libapr*
/usr/share/doc/packages/libapr-util1
/usr/share/doc/packages/libapr1
/usr/lib64/libaprutil-1.so.0.3.12
/usr/lib64/libapr-1.so.0.4.5
/usr/lib64/libaprutil-1.so.0
/usr/lib64/libapr-1.so.0
So I try
./configure --with-apr=/usr/lib64/libapr-1.so.0
configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
The same for --with-apr=/usr/lib64/libapr-1.so.0.4.5 and --with-apr=/usr/lib64/.
Which file does ./configure look for? What does --with-apr expect? Is one of the two *.so.* files the needed library?
You'll probably want to install libapr1-devel so that you can compile against it. Then try re-running ./configure.
I ran into the same issue, I think you're using the source code off of appache's site which I beleive is outdated. This issue has been fixed in the SVN trunk several years ago (lolol, I guess right around the time this question was asked).
Just pull the svn trunk's source and compile it:
svn checkout http://svn.apache.org/repos/asf/incubator/log4cxx/trunk apache-log4cxx
./autogen.sh
./configure
make
make check
sudo make install
On software.opensuse.org someone has packages built for recent versions of openSUSE as well as SLE at liblog4cxx10. Maybe that'll work for you instead of building your own.
MichaelGoren is right.
There is multiple ".h" file missing.
So you have to add them before launching make.
sed -i '1i#include <string.h>\n' src/main/cpp/inputstreamreader.cpp
sed -i '1i#include <string.h>\n' src/main/cpp/socketoutputstream.cpp
sed -i '1i#include <string.h>\n' src/examples/cpp/console.cpp
sed -i '1i#include <stdio.h>\n' src/examples/cpp/console.cpp
I bumped into the same problem on 3.3.4-5.fc17.x86_64 and resolved it by including the appropriate H files to the CPP files reported by the make utility.
In my case I should run the make utility 3 times each time getting a new error and fixing it by adding the appropriate include H to the reported CPP file.
The main idea is as following:
1) Check by running the man utility, where the function mentioned in the error defined.
For example, man memmove says that it is defined in the string.h header file.
2) Add the appropriate include file to the CPP file.
For example, the make utility complains that inputstreamreader.cpp does not find the memmove function. Open the inputstreamreader.cpp file and add string.h to its header files.
3) Run the make utility until the log4cxx is compiled without errors.

Can't get cygwin to compile C++ Boost libraries

I'm trying to get up and running with Boost, so I'm trying to compile the simple example problem from Boost's "Getting Started" page. I've had two issues, and I'm not sure they're related (I'm better than a novice, but not by much) but maybe they're related...
1st issue: the "tar --bzip2 -xf /path/to/boost_1_49_0.tar.bz2" command didn't work (yes, I put the correct path in, but it gave me some errors, I forget what they were) so I used "tar -xjvf " from the directory where boost_1_49_0.tar.bz2 was located. That de-compressed the zip file and I proceeded with the example...
2nd issue: The example.cpp file will not compile, the first statement in the code is #include "boost/lambda/lambda.hpp" but then for every header file lambda.hpp is trying access, there's a "No such file or directory" compile error. For example, here are two (of the six, and I get errors for all 6) header files within lambda.hpp and the errors displayed by the cygwin compiler:
boost/lambda/lambda.hpp:14:33: boost/lambda/core.hpp: No such file or directory
boost/lambda/lambda.hpp:21:52: boost/lambda/detail/operator_actions.hpp: No such file or directory
If it helps, this is the command I'm running to compile (I generally create the executable in a separate -o command):
g++ -c example.cpp
Why can't the system find these? I added the installed directory (path/to/boost_1_49_0) to the PATH variable before I started so I know that's no it. Thanks for any advice...
(I've looked on stackoverflow and there were similar issues, but no solutions that worked)
It looks like you've already solved the first issue: namely, that you must specify the -j flag on tar to untar a bzip2'd file.
For the second issue, you need to specify boost on your include path, either by specifying it with the -I command line option or via the CPLUS_INCLUDE_PATH environment variable.