How to link libraries in MinGW without makefile or any configuration? - static-linking

I'm going to give the source code of my program which need ws2_32 library to some rookie programmers who don't know a lot about c++. So it should be as simple as possible for them. the Compiler of Visual Studio supports #pragma comment with which i can add library but I don't know what to do with other compilers like MinGW or GCC. Is there any code that I can add to my source so that the library links automatically?

I would just write a makefile that pulls in all the stuff they need. Easiest for you and them I suppose.
Or is there any real reason not to handle it with makefiles? I can't imagine anything being much easier.

Related

I made a project in C++ CLI, But I can decompile it using a C# Decompiler

Is there any way, I can prevent my c++ cli project from being decompiled if someone uses a C# decompiler, because I tried to decompile the .exe i made in ILSpy and it showed my whole code, so is there any way I can prevent this?
Thanks
as ancient as this thread is, I ran across it with the same question, and a newish answer. Can't specify the minimum version for this one, but
[module:System::Runtime::CompilerServices::SuppressIldasmAttribute];
on top of each .cpp module did the trick for me:
I didn't investigate much further, yet.
Another useful thing is to add
#pragma unmanaged
to each .cpp that does not contain .net code.
You can
Use a .NET obfuscator.
Or
Only use C++CLI for the boundaries of your app which require to Interact with .NET. And implement your logic in a native C++ library.

Make command is usable for Objective-C project?

I'm looking for an Objective-C open source project with Makefile, but I didn't find anything like that. I need that to test my clang static analyser project. Is it possible to make an Objective-C project?
Using make for Objective C is certainly possible, and quite convenient.
Example is here: https://github.com/wkoszek/objc_edu/blob/master/makefile

How does Xcode know what symbols are in a project?

I was looking at doxygene and I noticed that its output for objective-C is less than optimal, so I was looking at doxygene's internals(in which all syntax analyzers consolidated into a huge blob), and then I decided that it was going to take a lot of work just to figure out where to begin with that.
So I thought, ok let's start by creating a dictionary/tree from an objective-c source file which it seems Xcode does already(because symbols are search able). And it seems to use LLVM"clang" somehow. Does anyone know how I can invoke "clang" to return a structure of the symbols in a project/document?
Xcode doesn't directly use the "clang++" binary for this purpose. The clang++ binary is actually a very small wrapper around the Clang C++ libraries. Xcode uses libclang (a C wrapper around the C++ libraries) for its C++ parsing needs.
Thus, to get the information you want, you will need to use libclang. On this page are the slides and video of a presentation Doug Gregor (the main developer of Clang) gave at the 2010 dev meeting entitled "libclang: Thinking Beyond the Compiler".
Many people in the clang community have expressed interest in replacing Doxygen's parser with clang. So you are not alone. However, I believe it is not a small project.

How to decompile an exe or a dll to assembly

I am really interested in assembly language and I want to learn about how exe files work how dlls run etc... and I have an idea of writing an application to decompile an exe to assembly code since i am not a very good assembly programmer and with the lack of knowledge of the inner working of exe I couldn't do it. Since I can read an exe in hex i think it is not impossible but I don't know how to write my own program. Any resources or any help would be appreciated.
I think you're looking for a disassembler not a decompiler. IDA pro seems to be popular and you can download an older version for free at http://www.hex-rays.com/idapro/idadownfreeware.htm
There are a lot of dissemblers already written for you (see above), but I don't think reading disassembled code is going to help you become a better assembly writer. The main reason for this is that compilers do A LOT of optimization before they generate assemblies. Often this makes for very tricky code to read but highly efficient code to analyze.
If you're interested in what a compiled program looks like at the a assembler level a much more meaningful approach would be compile and look at the generated assembly. For example with gcc/g++ this just requires gcc -c -S filename.c and will leave a clear text assembly file to look at.
Take a look at this Decompilation Wiki, I suspect it will answer most of your questions.

How do I expose erl_interface (Erlang's C library) through a DLL?

I've been working non-stop for the last three days on a completely managed interface to Erlang. At this point, I've decided that there simply must be an easier way. I've got a little over 3000 lines and it's not even in a compilable state yet. To be honest, I'm getting lost in my own code.
So, I then remembered that Erlang has a C library called erl_interface. Unfortunately, it only comes as a .LIB file, which isn't usable via P/Invoke. I'm now investigating ways to expose the static library through a DLL.
I'd like to stay away from Visual C++, mostly because I'm not a C/C++ programmer by nature and I find it really difficult to configure. TinyC is my compiler of choice when working with anything in C.
How can I go about this?
I know I can link erl_interface to a DLL, but how can I expose the functions? Do I have to essentially wrap each and every one of them in my own exports? That probably won't be a problem, since I could write a script to generate the code from the header file. But is there an easier way that I just don't know about?
Also, please don't recommend OTP.NET. It's a nice library, but I'm looking to use this is a large project, so I'd like to keep it in-house.
So, your problem is one of turning a static lib into a dynamic one.
The least-effort solution would be to write a thin shim file in 'C', that just delegates to the files in the .lib e.g.
ReturnType my_method1(args...) {
return real_method1(args...);
}
...
and build a DLL from that and the static lib.
Afterthought -- There is another approach you could take -- which is build the .lib into a C++/CLI assembly and do the transition/wrapping in that. It's what C++/CLi is there for, after all.
If you want some help with interfacing to Erlang with C, have a look at "EPAPI" (Erlang Port API) link text. You can of course browse the source code since it is hosted on Google Code. A DEBIAN repository is also available.