compilation

How to get your head around C++ linking/dependencies?

廉价感情. 提交于 2019-12-21 05:08:04
问题 I'm a Java developer and I never have to worry about including files or messing with BUILD files. Whenever I need to write C++ code, things get more complicated. I can think of creating *.h files as interfaces in Java, but figuring out how to write the build file and what order classes should be included in gives me a headache. Is there a simple way to think of this? How do you know when to include something or how to separate things out properly. For example, what is generally a good way to

why use g++ instead of gcc to compile *.cc files?

耗尽温柔 提交于 2019-12-21 05:04:32
问题 I compiled a library which use the g++ instead gcc. First I thought the source code was written in C++ but I found out later that there was not any C++ code in the *.cc files. To confirm this, I replaced the g++ in the original makefile with gcc. And I still got the correct program. Anyone can explain this? It was not the first time I met such a situation. 回答1: It depends on what exactly you changed in the makefile. gcc / g++ is really just a front-end driver program which invokes the actual

Compiling .NET code in .NET 4?

帅比萌擦擦* 提交于 2019-12-21 04:56:17
问题 I remember when .NET 4 was in beta there was a video of a developer that made a command-line app that he could type C# code into and it would compile the code on the fly. The idea was that the compiler was now available in the .NET language. Anyone recall where this is? I need to create an application with a small macro language and I would love to use C# as that macro language, but I don't know where to find this library.. 回答1: You can use the CSharpCodeProvider class to compile assemblies

LLVM: simple example of a just-in-time compilation

流过昼夜 提交于 2019-12-21 04:42:32
问题 I'm learning LLVM and trying to compile a simple function: int sum(int a, int b) { return a+b; }; on the fly. So here's the code I have so far: #include <string> #include <vector> #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Verifier.h" using namespace llvm; static LLVMContext &Context = getGlobalContext(); static std::unique_ptr<Module> MyModule = make_unique<Module>("my compiler", Context); Function *createFunc(IRBuilder<>

Should I Compile My Application Inside of a Docker Image

帅比萌擦擦* 提交于 2019-12-21 04:29:07
问题 Although most of the time I am developing Java apps and am simply using Maven so my builds should be reproducible (at least that's what Maven says). But say you are compiling a C++ program or something a little more involved, should you build inside of docker? Or ideally use vagrant or another technology to produce reproduce able builds. How do you manage reproducible build with docker? 回答1: You can, but not in your final image, as that would mean a much larger image than necessary: it would

extern enum in c++

心不动则不痛 提交于 2019-12-21 04:22:18
问题 I have an enum I have declared in some .h file: typedef enum { NONE, ONE, TWO, THREE } MYENUM; in a seperate .cpp I cannot do this: extern enum MYENUM; //works extern MYENUM TWO; //makes sence, TWO is not an INSTANCE of MYENUM... how would one do so without including the whole header where the enum is declared? 回答1: You can't use an incomplete type. You can only pass around pointers to it. This is because until the type is completed, the compiler doesn't know how big it is. OTOH a pointer is

Compiling against libusb-dev on Ubuntu

扶醉桌前 提交于 2019-12-21 04:22:18
问题 I am trying to compile the example libusb.c provided by libusb package (if you dl the source code.) It doesn't work to say the least. #include <stdio.h> #include <sys/types.h> #include <libusb/libusb.h> That causes it to fail, there is no libusb/libusb.h it's usb.h , so I change that. And it fails in new and innovative ways. I've copied the file over, exactly, and named it example.c I am using these commands and variations: gcc -o example example.c -lusb -L /usr/lib/libusb.a gcc -o example

How to compile file in clojure

喜夏-厌秋 提交于 2019-12-21 03:56:26
问题 I've created file "hello.clj" (ns clojure.examples.hello (:gen-class)) (defn -main [greetee] (println (str "Hello " greetee "!"))) and try to compile clojurec hello.clj But I got this error Exception in thread "main" java.io.FileNotFoundException: Could not locate hello/clj__init.class or hello/clj.clj on classpath: at clojure.lang.RT.load(RT.java:398) at clojure.lang.RT.load(RT.java:367) at clojure.core$load__5058$fn__5061.invoke(core.clj:3734) at clojure.core$load__5058.doInvoke(core.clj

Properly compiling modules in subfolders (ocamlbuild)

[亡魂溺海] 提交于 2019-12-21 03:54:06
问题 I recently decided to organize the files in my project directory. I moved the parsers I had for a few different file types into their own directory and also decided to use ocamlbuild (the as the project was getting more complicated and the simple shell script was not sufficient any longer). I was able to successfully include external projects by modifying myocamlbuild with some basic rules (calling ocaml_lib , I'll use ocamlfind some other time), but I am stuck on how to include the folder as

Cannot call member function without object = C++

会有一股神秘感。 提交于 2019-12-21 03:49:20
问题 I am brushing up again and I am getting an error: Cannot call member function without object. I am calling like: FxString text = table.GetEntry(obj->GetAlertTextID()); FxUChar outDescription1[ kCP_DEFAULT_STRING_LENGTH ]; IC_Utility::CP_StringToPString(text, &outDescription1[0] ); The line: IC_Utility::CP_StringToPString(text, &outDescription1[0] ); is getting the error My function is: void IC_Utility::CP_StringToPString( FxString& inString, FxUChar *outString) { } I know it has to be