compilation

pretty print makefiles

ε祈祈猫儿з 提交于 2019-12-20 09:39:19
问题 The linux kernel (and various other projects including git) have very nice makefiles that hide the giant cc calls into nice little acronyms. For example: gcc -O2 -o cool.o cool.c -llib gcc -O2 -o neat.o neat.c -llib would become: CC cool.c CC neat.c Which is really nice if you have a project with a large number of files and long compiler flags. I recall that this had to do with suppressing the default output and making a custom one. How do you do it? 回答1: You can prepend @ to calls in the

Why use #if 0 for block commenting out?

断了今生、忘了曾经 提交于 2019-12-20 09:28:23
问题 Reverse engineering code and I'm kind of appalled at the style, but I wanted to make sure there's no good reason for doing these things.... Is it just me or is this a horrible coding style if ( pwbuf ) sprintf(username,"%s",pwbuf->pw_name); else sprintf(username,"%d",user_id); And why wrap code not intended for compilation in an #if 0 .... #endif Instead of comments? EDIT: So as some explained below, this is due to the possibility to flummox /* */ which I didn't realize. But I still don't

The POM for project is missing, no dependency information available

风格不统一 提交于 2019-12-20 09:26:52
问题 Background Trying to add a Java library to the local Maven repository using a clean install of Apache Maven 3.1.0, with Java 1.7. Here is how the Java archive file was added: mvn install:install-file \ -DgroupId=net.sourceforge.ant4x \ -DartifactId=ant4x \ -Dversion=0.3.0 \ -Dfile=ant4x-0.3.0.jar \ -Dpackaging=jar This created the following directory structure: $HOME/.m2/repository/net/sourceforge/ant4x/ ├── 0.3.0 │ ├── ant4x-0.3.0.jar.lastUpdated │ └── ant4x-0.3.0.pom.lastUpdated └── ant4x ├

Why does compiling over 100,000 lines of std::vector::push_back take a long time?

时光总嘲笑我的痴心妄想 提交于 2019-12-20 09:23:51
问题 I'm compiling a C++ library which defines a single function that randomly samples from a set of data points. The data points are stored in a std::vector . There are 126,272 std::vector push_back statements, where the vector in question is of type double . It is taking a long time to compile. Why would this take so long? (All the code other than the std::vector push_back statements would take less than 1 second to compile, because there's very little other code.) 回答1: There is the -ftime

Makefile to Compile OpenCV Code in C++ on Ubuntu/Linux

心不动则不痛 提交于 2019-12-20 08:44:17
问题 I am learning OpenCV using Learning OpenCV book. One problem I am facing while compiling the code is that I have to write a long command to compile and get the executable. This is the command I am using g++ `pkg-config –cflags opencv` file_name.cpp -o output_file `pkg-config –libs opencv` I am no Make expert but I think I can eliminate writing that long command using make . Before that I should explain my work flow. I have created a directory called opencv in my home directory ( ~/opencv/ ).

invalid character name at (1)

冷暖自知 提交于 2019-12-20 06:32:39
问题 I am trying to compile a fortran code. It will analyze an X file in an Y directory and then create a new file Z with the results. But there is something wrong occurring. When I write the directory I see that it is too much for one line and then I try to continue it in the next one doing this: namech='/home/matheus/Documents/UFABC/IC/Spectra/Elliptical/' + 'espec.fits' But, when I try to compile using the command gfortran Codigo.f -o TESTE -Lcfitsio -lcfitsio I get this error message: + 'espec

libmodbus in MFC

旧街凉风 提交于 2019-12-20 06:07:59
问题 I am trying to integrate modbus library given by libmodbus into a custom MFC project in Visual Studio 2010. The steps that I have followed till now are as follows: 1) I have created project in Visual Studio 2010 as shown in snapshots below: 2) I have edited the code to include a small hello world code just to check if it compiles. 3) I have copied .c and .h files from src folder of libmodbus-3.0.3 to Visual Studio project folder as shown below and included them in the project. 4) When I try

Compiler is creating extra class files with $ in them

冷暖自知 提交于 2019-12-20 05:21:14
问题 I'm using Eclipse and I've written a Java application using SWT. When Eclipse compiles my program, it renames my main file into 4 different files like this: MainFile.class MainFile$1.class MainFile$2.class MainFile$3.class When I go to run this program from command line, I get Could not find the main class: MainFile.class. Program will exit. I really don't understand why this is happening. 回答1: The $ classes are for anonymous inner classes and perfectly normal. Could we see the command line

Incompatible Types Error in Java

亡梦爱人 提交于 2019-12-20 05:14:41
问题 I keep receiving an error that says that there are incompatible types. I copied this directly out of a book because we are supposed to make changes to the code to enhance the game of War. I have all of the other classes complete and compiled but this one is giving me fits. Here is the code: public class ArrayStack<E> implements Stack<E> { private E[] data; private int size; public ArrayStack() { data = (E[])(new Object[1]); size = 0; } public boolean isEmpty() { return size == 0; } public

Incompatible Types Error in Java

旧城冷巷雨未停 提交于 2019-12-20 05:13:42
问题 I keep receiving an error that says that there are incompatible types. I copied this directly out of a book because we are supposed to make changes to the code to enhance the game of War. I have all of the other classes complete and compiled but this one is giving me fits. Here is the code: public class ArrayStack<E> implements Stack<E> { private E[] data; private int size; public ArrayStack() { data = (E[])(new Object[1]); size = 0; } public boolean isEmpty() { return size == 0; } public