I need to find all *.exe and *.dll files in selected directory (with subdirectories). For determining *.exe I use GetBinaryType, but I can't to determine that current file is dll.
The part of code
if (GetBinaryType(wName, &binaryType) || /*condition: if wName is DLL*/) {
System::Diagnostics::Debug::WriteLine(fName);
}
Just read IMAGE_FILE_HEADER record of file. If Characteristics field contain IMAGE_FILE_DLL flag - you have dll.
Related
I am relatively new to make and don't know how to do one specific thing:
The overall process should look something like this:
the source files are java sources in a directory like src/org/path/to/packages/*.java
I want only to translate a specific java file, but the translation process will automatically translate all dependencies (I say 'translate' because I use j2objc to translate the java files to obj-c files - but that should be of no concern for this question)
The translated files will be put into the build/ directory with a folder structure reflecting the source folder structure (so build/org/path/to/packages/.m+.h)
These *.m and *.h files will then be compiled with j2objcc (a clang wrapper) into *.o files -> this step has to be done per file so every file is compiled with a command like j2objcc -c build/org/path/to/packages/file1.m -o build/org/path/to/package/file1.o
these shall be combined into a static library using ar
My problem is that I know which (one) java file I am starting with, but after step 2 I don't know which *.m and *.h files are generated/translated into the build directory. I'd like to read the contents of the build dir after step 2 with a command like find ./build -name '*.m' at make runtime but I don't know how to use this as a prerequisite in the make target.
It is possible with MSVC to create a so-called resource-only DLL which essentually is a DLL that contains no machine code, but only resources. Is there a way to create a DLL only resource file using mingw? (If not possible, is it possible using open source tools?)
I know you can use windres to compile rc files into .res files. But the resources are appended with the compiler. but what if I have nothing to compile?
windres documentation says you can compile resources to coff object format and link it:
The normal use is for you to write an rc file, use windres to convert it to a COFF object file, and then link the COFF file into your application.
If the input or output format is not specified, windres will guess based on the file name, or, for the input file, the file contents. A file with an extension of .rc will be treated as an rc file, a file with an extension of .res will be treated as a res file, and a file with an extension of .o or .exe will be treated as a coff file.
So, e.g. with my.rc:
1 BITMAP "Untitled.bmp"
You can build it into dll by invoking:
windres -i my.rc -o my.o
ld --dll -o my.dll my.o
There are two shared libraries that are the same name but different suffixes. eg. (A.dll and A.lib). Now when I use the command “make” to make C codes, the compiler chooses the A.lib as the default option. Then how can I choose the flexibly library I need? And the following code is the code of makefile.
CC = gcc
COSI_LIB = '/C/A'
OBJ_NAME = B.exe
SOURCE = B.c
${OBJ_NAME}: ${SOURCE}
#$(CC) -I${COSI_LIB} -L${COSI_LIB} -lA -o ${OBJ_NAME} ${SOURCE}
clean:
#rm $(OBJ_NAME) -r -f
I need to know that When there are two same name files but different format (ex. One named abc.dll and another named abc.lib) and I input command ‘make’ on term, I wish that compiler select .dll file instead of .lib file.
First, the compiler doesn't care about any .lib or .dll files, only the linker does.
Second, on Windows, the linker never uses .dlls. It always uses .lib, and it is the .lib file which contains either .o files (which are linked directly into your binary), or "dll imports", which tell the linker to build "import tables" to be used at runtime to import the functions from a corresponding .dll.
That is (unlike on UNIX) you don't get to decide whether to link against .lib or .dll (you always link against .lib). Whoever built the .lib and the .dll decided which (if any) parts are to be linked in directly, and which are to be imported from the .dll.
When a file contains an include line like this:
#include "name.h"
gcc (and other C compilers) search for the file "name.h" in the directory containing the file being compiled. This does not by default happen if the line looks like this:
#include <name.h>
Is there an option to gcc to make it behave this way in the latter case too? As noted in the gcc documentation, "-I. searches the compiler's current working directory for header files. That may or may not be the same as the directory containing the current file." In the case I am working on (importing external code that used a build environment that automatically added the containing directory to the search path into a system that doesn't have such a build facility), the current directory is unfortunately not the same. What can I do? I'd rather not have to specifically modify the files...
for a VisualStudio project, i'd like cMake to put all files from a specific folder into a specific filter.
I tried:
SOURCE_GROUP(Math FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.h
)
however, this will place only the first found cpp and the first found h file into that filter. the rest of the files in the folder will be placed in the default Filters
How to do it properly?
You need to pass full names, not globbing expressions:
FILE(GLOB source_files
${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.h
)
SOURCE_GROUP(Math FILES ${source_files})