Error when using Mingw on Windows - linux

I am completely new to this. I have a C program which compiles fine and runs fine on linux. I want to run the same code on a Windows machine so I am using the cross compiler Mingw. However every time i try and build the project i get this error:
14:51:21 **** Incremental Build of configuration Default for project zbar-0.10 ****
make all
make all-am
make[1]: Entering directory `D:/zbar-0.10'
! was unexpected at this time.
make[1]: *** [include/config.h] Error 255
make[1]: Leaving directory `D:/zbar-0.10'
make: *** [all] Error 2
14:51:26 Build Finished (took 4s.493ms)
I have googled around and still do not understand why i am getting it. Any advice?

Build with exact versions of tools as specified in: http://sourceforge.net/apps/mediawiki/zbar/index.php?title=HOWTO:_Compile_with_MinGW_in_Windows
The code is old and the make will break with newer versions.

Related

Problems building driver on Linux kernel 5.8.x

I'm working with a Linux driver that is building on v5.7.x kernels but not on the latest v5.8.x releases.
To summarise, most of the driver is pre-built and the kernel interface is built on the target. This involves a make -f Kbuild command.
Having checked all of the relevant kernel interface files for any changes that would affect us, normally the driver would just build as usual on a new kernel. However, this time we get the following error:
make[2]: *** [scripts/Makefile.modpost:111: /path/to/source/Module.symvers] Error 1
make[1]: *** [Makefile:1669: modules] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.8.0-1.el8.elrepo.x86_64'
make: *** [Kbuild:26: default] Error 2
This is from CentOS 8.1, but the same error has been seen on Ubuntu 20.04.
I am no expert on this so interpreting these errors is a bit difficult. I have tried building with the KBUILD_VERBOSE flag and it doesn't really provide any useful information, other than the build succeeding until this point.
On previous kernels the Module.symvers file would be created but empty. On 5.8 this file is not created at all presumably due to this error. As a result, the .ko file is not created.
Finally, if we drop in the source files rather than the pre-built .o files the build does succeed. These .o files are built with a very old version of GCC (4.4.7) but we have also tried building with a much newer version (8.3.1), the same version as the target machine.
I would appreciate suggestions for things to check. Let me know if any other details would help.
Edit:
I ran make on Makefile.modpost manually and got the following output:
sudo make -f ./scripts/Makefile.modpost
WARNING: Symbol version dump "vmlinux.symvers" is missing.
Modules may not have dependencies or modversions.
make -f /scripts/Makefile.modfinal
make[1]: Entering directory '/usr/src/linux-headers-5.8.0-050800-generic'
make[1]: /scripts/Makefile.modfinal: No such file or directory
make[1]: *** No rule to make target '/scripts/Makefile.modfinal'. Stop.
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-050800-generic'
make: *** [scripts/Makefile.modpost:117: __modpost] Error 2
I am answering my own question in case it helps anyone else with this problem. Although it has never been an issue in the past, we've always had a warning that the corresponding .o.cmd file was not present for our .o_shipped files. This appears to be important in kernel 5.8 onwards and my fix was to add a touch command to the Kbuild file (i.e. "touch .driver.o.cmd"). This does not remove the warning but it allows the driver to build as normal.

Linux kernel 'make rpm-pkg' throws error

I am trying to create a custom kernel rpm. So I made use of "make rpm-pkg".
Everything was going fine until it hit this error.
..
..
INSTALL sound/usb/line6/snd-usb-toneport.ko
INSTALL sound/usb/line6/snd-usb-variax.ko
INSTALL sound/usb/misc/snd-ua101.ko
INSTALL sound/usb/snd-usb-audio.ko
INSTALL sound/usb/snd-usbmidi-lib.ko
scripts/Makefile.fwinst:43: *** mixed implicit and static pattern rules. Stop.
make[2]: *** [_modinst_post] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.jJi4sq (%install)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.p88MqU (%install)
make[1]: *** [rpm-pkg] Error 1
make: *** [rpm-pkg] Error 2
I understand there is something wrong with Makefile declarations, but also wondering if anyone has hit this issue.
If you are using make version 3.81 or 3.82 then this is likely the known make "bug" discussed here.
Specifically a change to what make believes is a meaningful set of targets to specify in a single list changed in an incompatible way and the kernel had been using a set of targets that became invalid.
The fix, after some back and forth between the GNU Make maintainer and some concerned other developers, was to convert the fatal error into a warning (at least temporarily).
I was able to fix this. Apparently its an issue with the UTS_MACHINE not being right for arm64. It should be aarch64 so that the packaging scripts use it right. there's also small tweak in the script that generates the rpm spec file.
So 'make' is not an issue in this case.

How to create a .dll from Netbeans using Linux?

I'm working on a Linux machine (debian) 64bit and created a simple project involving JNI. The program is running fine on Linux with the created Java project and the compiled .so file. The goal now is to compile the C++ part of the project into a .dll instead of a .so to get it to run on Windows machines.
I read some forums and some articles like this one Article, but all of those articles were about compiling from console and also didn't involve the necessary JNI includes.
I also downloaded the cross-compiler from the given article and tried to get it to run in Netbeans. Therefore I set up another C/C++ Tool Collection in Netbeans and told it to use the x86_64-w64-mingw32-gcc compiler for both C and C++. But Netbeans is giving me some errors compiling the file, telling me the x86_64-w64-mingw32-gcc compiler could not be found which is quite random I think because I selected it from the file chooser. Did any of you do something like this already, building a .ddl from Netbeans running on Linux? If yes, how did you get it to work?
x86_64-w64-mingw32-gcc: not found
bproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/GNU_1-Linux-x86/WrapperCpp.o' failed
make[2]: *** [build/Debug/GNU_1-Linux-x86/WrapperCpp.o] Error 127
make[2]: Leaving directory
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
#Edit: I'm a step further now: I installed the correct mingw32 tools: sudo apt-get install mingw32. The programm does now compile without errors using the i586-mingw32msvc-g++ compiler but it still results in a .so instead of a .dll. I guess it has something to do with the make command but I haven't found anything about that yet.

Error During Compilation of GNU C Library (glibc)

I'm not experienced with system administration, nor the technical details of compiling C-based programs, so bear with me if I say something inaccurate.
Basically, I'm using a computing cluster that has a relatively old OS (Red Hat Enterprise Linux 4.3, from ~2006), for which I have no root access. I recurrently run into issues when compiling various programs. One common cause I can see is outdated libraries, notably the C library. I decided to compile a recent version of glibc, thinking that linking to this new C library would solve many of my problems (is this sound?). That lead me down a rabbit hole of installing a more recent version of gcc and its dependencies (including modern Linux kernel headers).
In any case, I believe I have a working version of gcc. Now, when I attempt to compile glibc using this new gcc, I run into an error during the compilation, as follows (these are the last few lines):
[...]
make[2]: Leaving directory `/home/bgrande/software/apollo/src/glibc-2.19/login'
make subdir=elf -C elf ..=../ subdir_lib
make[2]: Entering directory `/home/bgrande/software/apollo/src/glibc-2.19/elf'
Makefile:896: *** target `.dyn' leaves prerequisite pattern empty. Stop.
make[2]: Leaving directory `/home/bgrande/software/apollo/src/glibc-2.19/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/home/bgrande/software/apollo/src/glibc-2.19'
make: *** [all] Error 2
I'm at a loss at understanding what
Makefile:896: *** target `.dyn' leaves prerequisite pattern empty. Stop.
means and, more importantly, what could possibly solve this. Google and Stack Overflow searches haven't turned anything up.
I'm aware that this is probably due to something relative to my system environment, although I wouldn't know what exactly. If ever I can provide additional information that could help, let me know. I would appreciate a solution, but also a rationale for the solution and perhaps a way of interpreting the error for future reference. Thank you!
Update: Installing a more recent version of Make (make-4.0) as per #andrewdotn's suggestion did resolve the error, but another one crops up later in the compilation (see below). Any ideas?
[...]
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(ns_print.os): In function `__GI_ns_sprintrrf':
/home/bgrande/software/apollo/src/glibc-2.19/resolv/ns_print.c:99: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/src/glibc-2.19/resolv/ns_print.c:728: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(gethnamaddr.os): In function `getanswer':
/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:180: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:483: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(gethnamaddr.os): In function `__GI_res_gethostbyname2':
/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:510: undefined reference to `__stack_chk_guard'
/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv_pic.a(gethnamaddr.os):/home/bgrande/software/apollo/src/glibc-2.19/resolv/gethnamaddr.c:636: more undefined references to `__stack_chk_guard' follow
collect2: error: ld returned 1 exit status
../Makerules:438: recipe for target '/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv.so' failed
make[2]: *** [/home/bgrande/software/apollo/glibc-2.19/resolv/libresolv.so] Error 1
make[2]: Leaving directory '/home/bgrande/software/apollo/src/glibc-2.19/resolv'
Makefile:213: recipe for target 'resolv/others' failed
make[1]: *** [resolv/others] Error 2
make[1]: Leaving directory '/home/bgrande/software/apollo/src/glibc-2.19'
make: *** [all] Error 2
That sounds like it’s caused by an old version of Make. RHEL 4.3 uses Make 3.80 from 2002. Try downloading Make 3.82 or 4.0 from ftp.gnu.org, building it in your home directory, and using that to drive the compile.

Linux 3.13 Kernel Fails to Compile

After configuring various options inside .conf using
$make config
I try to compile the entire linux kernel using
$make
However it throws an error as below:
root#localbox:/LinuxKernel/linux-3.13# make
scripts/kconfig/conf --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `relocs'.
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
root#localbox:/LinuxKernel/linux-3.13#
I tried to search for .conf by using:
$find -name ".conf"
However it turns up no results. But since make config worked I assume .config must exist somewhere.
Please advise me on how to overcome this annoying problem. I am doing this for the first time and I am not sure if there are any dependencies that have to be installed before trying to compile the kernel. Your feedbacks are highly appreciated.
There must have been some error with make config, e.g. disk full or you aborted it with Ctrl-C. The .config file (not .conf) is right in the main directory.
The error message says it already
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
There are several textbased (config, oldconfig, menuconfig) and graphical (xconfig, gconfig) configuration programs. You might want to pick a graphical one and run it, e.g.
make gconfig
These graphical configurators also help to avoid all the hundreds of irrelevant questions. When you're done selecting the needed options, don't forget to save the .config file and try again compiling the kernel and modules.

Resources