When compiling a Linux program, if there is an error:
“File format not recognized”
In general, XXX. O in makefile If it is wrongly written as XXX. C, it can be corrected.
When compiling a Linux program, if there is an error:
“File format not recognized”
In general, XXX. O in makefile If it is wrongly written as XXX. C, it can be corrected.
The system cannot find the path specified
If you report an error when creating a directory, it is recommended that you check the following:
err := os.Mkdir(path, perm)
If you use the above method, you can only create a single level directory
if you want to create a directory such as XX/YY, XX/YY/ZZ,…
please enter the following method
err := os.MkdirAll(path, perm)
OK! Problem solved!
First, Download cbmakegen from the official website
Official website address: http://developer.berlios.de/projects/cbmakegen/
Can also be downloaded through my baidu disk
[Windows version] address: http://pan.baidu.com/share/link?shareid=123030&uk=1227046485
[Linux version] address: http://pan.baidu.com/share/link?shareid=123067&uk=1227046485
【Windows】
Decompress cbmakefilegen-bin-0.3.12.5-win32
obtain cbMakefileGen.cbplugin
Open plugins – & gt; manage plugins in the code:: blocks interface
add to cbMakefileGen.cbplugin
Then the generate makefile option will appear in the Project menu to export the makefile
It appears in the project directory Makefile.gen
Add driver/libdriver.a to /app/Makefile and add Makefile files to /app/driver (it is recommended to copy /examples/IoT_Demo folder and delete other files that are not needed. Be sure not to delete Makefile files by mistake).
QApplication> Only the declaration is introduced, but there is no lib, so the link will fail.
make
this program will look for a file named
makefile in your directory, and then execute it.
If you have several makefiles, then you can execute them with the command:
make -f MyMakefile
There are several other switches to the
make
utility. For more info,
man make
.
Build Process
Compiling by hand The trivial way to compile the files and obtain an executable, is by running the command:
g++ main.cpp hello.cpp factorial.cpp -o hello
The basic Makefile The basic makefile is composed of:
target: dependencies [tab] system command
This syntax applied to our example would look like:
all: g++ main.cpp hello.cpp factorial.cpp -o hello
[Download
here]
To run this makefile on your files, type:
make -f Makefile-1
On this first example we see that our target is called
all. This is the default target for makefiles. The
make utility will execute this target if no other one is specified.
We also see that there are no dependencies for target
all, so
make safely executes the system commands specified.
Finally, make compiles the program according to the command line we gave it.
Using dependencies Sometimes is useful to use different targets. This is because if you modify a single file in your project, you don’t have to recompile everything, only what you modified.
Here is an example:
all: hello hello: main.o factorial.o hello.o g++ main.o factorial.o hello.o -o hello main.o: main.cpp g++ -c main.cpp factorial.o: factorial.cpp g++ -c factorial.cpp hello.o: hello.cpp g++ -c hello.cpp clean: rm -rf *o hello
[Download
here]
Now we see that the target all has only dependencies, but no system commands. In order for make to execute correctly, it has to meet all the dependencies of the called target (in this case all).
Each of the dependencies are searched through all the targets available and executed if found.
In this example we see a target called clean. It is useful to have such target if you want to have a fast way to get rid of all the object files and executables.
Using variables and comments You can also use variables when writing Makefiles. It comes in handy in situations where you want to change the compiler, or the compiler options.
# I am a comment, and I want to say that the variable CC will be # the compiler to use. CC=g++ # Hey!, I am comment number 2. I want to say that CFLAGS will be the # options I'll pass to the compiler. CFLAGS=-c -Wall all: hello hello: main.o factorial.o hello.o $(CC) main.o factorial.o hello.o -o hello main.o: main.cpp $(CC) $(CFLAGS) main.cpp factorial.o: factorial.cpp $(CC) $(CFLAGS) factorial.cpp hello.o: hello.cpp $(CC) $(CFLAGS) hello.cpp clean: rm -rf *o hello
[Download
here]
As you can see, variables can be very useful sometimes. To use them, just assign a value to a variable before you start to write your targets. After that, you can just use them with the dereference operator $(VAR).
Where to go from here With this brief introduction to Makefiles, you can create some very sophisticated mechanism for compiling your projects. However, this is just a tip of the iceberg. I don’t expect anyone to fully understand the example presented below without having consulted some
Make documentation (which I had to do myself) or read pages 347 to 354 of your Unix book.
CC=g++ CFLAGS=-c -Wall LDFLAGS= SOURCES=main.cpp hello.cpp factorial.cpp OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=hello all: $(SOURCES) $(EXECUTABLE) $(EXECUTABLE): $(OBJECTS) $(CC) $(LDFLAGS) $(OBJECTS) -o $@ .cpp.o: $(CC) $(CFLAGS) $< -o $@
[Download
here]
If you understand this last example, you could adapt it to your own personal projects changing only 2 lines, no matter how many additional files you have !!!.
Hector Urtubia
Compiler Error on Linux systems: suffix or operands invalid for ‘vbroadcastss’ solution Error scenario solution reference
Error: suffix or operands invalid for ‘vbroadcastss’ solution
When running Kaggle-2014-Criteo-Master open source program, I encountered errors when compiling and running GBDT, libffm program and Makefile. The intuition was related to the system running the program. A search led to a solution. The
problem is primarily that GCC or g++ compile-time sets the -march parameter, which is a platform-dependent parameter. You need to modify this parameter value to correspond to the machine.
(program download address: https://github.com/ycjuan/kaggle-2014-criteo)
for this open source programs need to modify: Makefile
[file path]/kaggle-2014-criteo/solvers/ GBDT
[file path]/kaggle-2014-criteo/solvers/libffm-1.13 Makefile
-march =native march=broadwel
then Makefile error disappears.
An error scenario
Specifically report the following mistakes:
[dhy@Master kaggle-2014-criteo-master]$ make
make -C solvers/gbdt
make[1]: Entering directory `/home/dhy/code/kaggle-2014-criteo-master/solvers/gbdt'
g++ -Wall -Wconversion -O2 -fPIC -std=c++0x -march=native -fopenmp -o gbdt src/train.cpp src/common.cpp src/timer.cpp src/gbdt.cpp
make[1]: Leaving directory `/home/dhy/code/kaggle-2014-criteo-master/solvers/gbdt'
ln -sf solvers/gbdt/gbdt
make -C solvers/libffm-1.13
make[1]: Entering directory `/home/dhy/code/kaggle-2014-criteo-master/solvers/libffm-1.13'
g++ -Wall -O3 -std=c++0x -march=native -fopenmp -DUSEOMP -c -o ffm.o ffm.cpp
/tmp/ccuUtD2f.s: Assembler messages:
/tmp/ccuUtD2f.s:3671: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccuUtD2f.s:3787: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccuUtD2f.s:3917: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccuUtD2f.s:4071: Error: suffix or operands invalid for `vbroadcastss'
make[1]: *** [ffm.o] Error 1
make[1]: Leaving directory `/home/dhy/code/kaggle-2014-criteo-master/solvers/libffm-1.13'
make: *** [ffm-train] Error 2
The solution
Modify the Makefile, – march = native for – march = broadwell
this is because the GCC/g + + parameters march on different architecture platform corresponding to different – march Options, refer to: https://gcc.gnu.org/onlinedocs/gcc in the “3.18 Machine – Dependent Options” section. To view the machine’s corresponding -march, run the following command 1 :
$gcc -c -Q -march=native --help=target | grep march
My machine to execute the above command appears:
-march= broadwell
Therefore, in the compile file Makefile, the g++ or GCC parameter is set to -march= broadwell.
different cpus corresponding to march selection can refer to the following table: 2
The
CPU type th> | march option th> tr> |
---|---|
AMD Barcelona td> | – march = Barcelona td> tr> |
AMD Bobcat td> | – march = btver1 td> tr> |
AMD Jaguar | – march=btver2 |
AMD Bulldozer | – march=bdver1 |
AMD Piledriver | – march=bdver2 |
AMD Steamroller | – march=bdver3 |
Intel Westmere | – march=westmere |
Intel Core Nehalem | – march=corei7 |
Intel Core Sandy Bridge | – march=corei7-avx |
Intel Core Ivy Bridge | – march=core-avx-i |
Intel Core Haswell | – march=core-avx2 |
Intel Core Broadwell | – march=broadwell |
Intel Atom Bonnell | – march=bonnell |
Intel Atom Silvermont | – march=silvermont |
reference
reason: according to the Makefile gsm2.mak description, emigen is dependent on sysgen, sysgen is dependent on cmmgen, and new dependent
cmmgen. So this error happens when you make new, Be emigen Missing several dependent files
custom/system/NEOTEL25_06B_BB/ custom_emine.c
custom/system/NEOTEL25_06B_BB/ custom_emine.h
custom/system/NEOTEL25_06B_BB/flash_opt.h
custom/system/NEOTEL25_06B_BB/ custom_switch_clock C
the make/Gsm2 mak
— — — — — — — — — — — — — — — —
new: cleanall cmmgen asngen codegen asnregen The update
cmmgen: sysgen
sysgen: emigen
emigen: $$(FLASH_OPTIONS_HDR) (strip) $$(CUSTOM_EMI_H) (strip) $$(CUSTOM_EMI_C) (strip) $$(SWITCH_CLK_C) (strip)
@ echo the Generate EMI Settings
@ if exist $$(EMI_GENERATOR) (strip)/
(perl $$(EMI_GENERATOR) (strip) $(strip $(PLATFORM)) $$(MCU_CLOCK) (strip) $$(MEMORY_DEVICE_HDR) (strip) $$(MEMORY_DEVICE_LST) (strip)) 2 & gt; & 1
— — — — — — — — — — — — — — — — — — — — — — —
the variable $(PLATFORM), $(MCU_CLOCK) have NEOTEL25_06B_GPRS. Mak is defined.
variables $(EMI_GENERATOR), $(MEMORY_DEVICE_LST), $(MEMORY_DEVICE_HDR) are defined in option. mak.
so if the above source file is missing, Then make will call./tools/ emigenv2.pl to execute
./tools/ emigenv2.pl MT6225 MCU_104M Custom/system/NEOTEL25_06B_BB/custom_MemoryDevice. H.
/tools/MemoryDeviceList/MemoryDeviceList_Since06BW0652. XLS
emiGenV2. Pl is a Perl script, which invokes the Win32: : OLE libraries for Microsoft Office Excel file parsing.
if Excel is not installed, the above error message will be generated. Reference
http://bytes.com/topic/perl/answers/681606-win32-ole-error-no-type-library-matching-microsoft-excel-found
summary: keep the source code file is missing source file, or install MS Office Excel.