I'm trying to modify oclvanitygen [link], and I've done some of that. Now I need to test it, but I'm having trouble compiling it on Windows 7. I'm using the VS Command Prompt in VC++ 2010 Express to run a makefile. The relevant parts of the makefile, as modified by me:
CC = cl
OPENSSL_DIR = [Working Dir]\openssl
PTHREADS_DIR = [Working Dir]\pthread
PCRE_DIR = [Working Dir]\pcre
CURL_DIR = C:\curl-7.26.0-x86\builds\libcurl-release-static-ssl-static-ipv6-sspi
OPENCL_DIR = [Working Dir]\openCL
OPENCL_INCLUDE = /I$(OPENCL_DIR)\include
OPENCL_LIBS = $(OPENCL_DIR)\OpenCL.lib
CURL_INCLUDE = /I$(CURL_DIR)\include /DCURL_STATICLIB
CURL_LIBS = $(CURL_DIR)\lib\libcurl_a.lib
CFLAGS_BASE = /D_WIN32 /DPTW32_STATIC_LIB /DPCRE_STATIC /I$(OPENSSL_DIR)\inc32 /I$(PTHREADS_DIR) /I$(PCRE_DIR) /Ox /Zi
CFLAGS = $(CFLAGS_BASE) /GL
LIBS = $(OPENSSL_DIR)\out32\libeay32.lib $(PTHREADS_DIR)\pthreadVC2.lib $(PCRE_DIR)\pcre.lib ws2_32.lib user32.lib advapi32.lib gdi32.lib /LTCG /DEBUG
OBJS = vanitygen.obj oclvanitygen.obj oclengine.obj oclvanityminer.obj keyconv.obj pattern.obj util.obj winglue.obj
all: vanitygen.exe keyconv.exe
vanitygen.exe: vanitygen.obj pattern.obj util.obj winglue.obj
link /nologo /out:$# $** $(LIBS)
oclvanitygen.exe: oclvanitygen.obj oclengine.obj pattern.obj util.obj winglue.obj
link /nologo /out:$# $** $(LIBS) $(OPENCL_LIBS)
oclvanityminer.exe: oclvanityminer.obj oclengine.obj pattern.obj util.obj winglue.obj
link /nologo /out:$# $** $(LIBS) $(OPENCL_LIBS) $(CURL_LIBS)
keyconv.exe: keyconv.obj util.obj winglue.obj
link /nologo /out:$# $** $(LIBS)
.c.obj:
#$(CC) /nologo $(CFLAGS) /c /Tp$< /Fo$#
oclengine.obj: oclengine.c
#$(CC) /nologo $(CFLAGS_BASE) $(OPENCL_INCLUDE) /c /Tpoclengine.c /Fo$#
oclvanitygen.obj: oclvanitygen.c
#$(CC) /nologo $(CFLAGS_BASE) /c /Tpoclvanitygen.c /Fo$#
oclvanityminer.obj: oclvanityminer.c
#$(CC) /nologo $(CFLAGS_BASE) $(CURL_INCLUDE) /c /Tpoclvanityminer.c /Fo
clean:
del vanitygen.exe oclvanitygen.exe oclvanityminer.exe keyconv.exe $(OBJS)
Then I use the command
nmake /fmakefile.win32 oclvanitygen.exe
It fails with the following error:
link /nologo /out:oclvanitygen.exe oclvanitygen.obj oclengine.obj pattern.obj util.obj winglue.obj [Working Dir]\openssl\out32\libeay32.lib [Working Dir]\pthread\pthreadVC2.lib [Working Dir]\pcre\pcre.lib ws2_32.lib user32.lib advapi32.lib gdi32.lib [Working Dir]\openCL\OpenCL.lib /LTCG /DEBUG
LINK : fatal error LNK1117: syntax error in option ''
NMAKE: fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.EXE"' : return code '0x45d'
What am I doing wrong? All of the header files and libs are in their correct places.
Related
On Qt5 project using Microsoft compiler, the qmake .pro project file have
DATE = $$system(wmic os get LocalDateTime > $$OUT_PWD/wmic.txt)
DATE = $$cat($$OUT_PWD/wmic.txt)
DATE = $$split(DATE, ' ')
DATE = $$member(DATE, 1)
DATE = $$split(DATE, .)
DATE = $$member(DATE, 0)
DATE = $$str_member($$DATE, 0, 7)
message($${DATE})
# DATE = 20220506 # comment this line will led to error LNK1117
message($${DATE})
YEAR = $$str_member($$DATE, 0, 3)
MONTH = $$str_member($$DATE, 4, 5)
VERSION = $${YEAR}.$${MONTH}
message($$VERSION)
The DATE = 20220506 is supposed to have same value as logic above it will set. However if I comment that line it will led to error error LNK1117.
What am I missing?
I'm about to conclude VERSION is read at an early stage when DATE is not ready yet. In this case, how can I make DATE to be computed earlier?
Here is what I see in the QtCreator terminal:
20:03:54: Running steps for project project...
20:03:54: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" clean
C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug clean
del debug\moc_predefs.h
del debug\moc_widget.cpp
del debug\main.obj debug\widget.obj debug\moc_widget.obj
del debug\project.vc.pdb debug\project.ilk debug\project.idb
del debug\project_resource.res
C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Release clean
del release\moc_predefs.h
del release\moc_widget.cpp
del release\main.obj release\widget.obj release\moc_widget.obj
del release\project_resource.res
Could Not Find C:\Users\user\QtProjects\project\_x64d\release\moc_predefs.h
Could Not Find C:\Users\user\QtProjects\project\_x64d\release\moc_widget.cpp
Could Not Find C:\Users\user\QtProjects\project\_x64d\release\main.obj
Could Not Find C:\Users\user\QtProjects\project\_x64d\release\project_resource.res
del project.vc.pdb
Could Not Find C:\Users\user\QtProjects\project\_x64d\project.vc.pdb
del project.ilk
Could Not Find C:\Users\user\QtProjects\project\_x64d\project.ilk
del project.idb
Could Not Find C:\Users\user\QtProjects\project\_x64d\project.idb
20:03:54: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally.
20:03:54: Starting: "C:\Qt\5.15.2\msvc2019_64\bin\qmake.exe" C:\Users\user\QtProjects\project\project.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
C:/Users/user/QtProjects/project/project.pro:24: message(message) requires one argument.
C:/Users/user/QtProjects/project/project.pro:26: message(message) requires one argument.
Project MESSAGE: .
C:/Users/user/QtProjects/project/project.pro:24: message(message) requires one argument.
C:/Users/user/QtProjects/project/project.pro:26: message(message) requires one argument.
Project MESSAGE: .
C:/Users/user/QtProjects/project/project.pro:24: message(message) requires one argument.
C:/Users/user/QtProjects/project/project.pro:26: message(message) requires one argument.
Project MESSAGE: .
20:03:54: The process "C:\Qt\5.15.2\msvc2019_64\bin\qmake.exe" exited normally.
20:03:54: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" -f C:/Users/user/QtProjects/project/_x64d/Makefile qmake_all
jom 1.1.3 - empower your cores
20:03:54: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally.
20:03:54: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe"
C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++17 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\project.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\..\project -I. -IC:\Qt\5.15.2\msvc2019_64\include -IC:\Qt\5.15.2\msvc2019_64\include\QtWidgets -IC:\Qt\5.15.2\msvc2019_64\include\QtGui -IC:\Qt\5.15.2\msvc2019_64\include\QtANGLE -IC:\Qt\5.15.2\msvc2019_64\include\QtCore -Idebug -I/include -IC:\Qt\5.15.2\msvc2019_64\mkspecs\win32-msvc -Fodebug\ #C:\Users\user\AppData\Local\Temp\main.obj.125924.0.jom
main.cpp
rc /NOLOGO -D_DEBUG -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -fo debug\project_resource.res project_resource.rc
cl -BxC:\Qt\5.15.2\msvc2019_64\bin\qmake.exe -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++17 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E C:\Qt\5.15.2\msvc2019_64\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h
C:\Qt\5.15.2\msvc2019_64\bin\moc.exe -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --compiler-flavor=msvc --include C:/Users/user/QtProjects/project/_x64d/debug/moc_predefs.h -IC:/Qt/5.15.2/msvc2019_64/mkspecs/win32-msvc -IC:/Users/user/QtProjects/project -IC:/Qt/5.15.2/msvc2019_64/include -IC:/Qt/5.15.2/msvc2019_64/include/QtWidgets -IC:/Qt/5.15.2/msvc2019_64/include/QtGui -IC:/Qt/5.15.2/msvc2019_64/include/QtANGLE -IC:/Qt/5.15.2/msvc2019_64/include/QtCore -I. -I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29910\ATLMFC\include" -I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29910\include" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" ..\widget.h -o debug\moc_widget.cpp
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++17 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\project.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\..\project -I. -IC:\Qt\5.15.2\msvc2019_64\include -IC:\Qt\5.15.2\msvc2019_64\include\QtWidgets -IC:\Qt\5.15.2\msvc2019_64\include\QtGui -IC:\Qt\5.15.2\msvc2019_64\include\QtANGLE -IC:\Qt\5.15.2\msvc2019_64\include\QtCore -Idebug -I/include -IC:\Qt\5.15.2\msvc2019_64\mkspecs\win32-msvc -Fodebug\ #C:\Users\user\AppData\Local\Temp\widget.obj.125924.0.jom
widget.cpp
cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++17 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -EHsc /Fddebug\project.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\..\project -I. -IC:\Qt\5.15.2\msvc2019_64\include -IC:\Qt\5.15.2\msvc2019_64\include\QtWidgets -IC:\Qt\5.15.2\msvc2019_64\include\QtGui -IC:\Qt\5.15.2\msvc2019_64\include\QtANGLE -IC:\Qt\5.15.2\msvc2019_64\include\QtCore -Idebug -I/include -IC:\Qt\5.15.2\msvc2019_64\mkspecs\win32-msvc -Fodebug\ #C:\Users\user\AppData\Local\Temp\moc_widget.obj.125924.265.jom
moc_widget.cpp
link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /VERSION:. /MANIFEST:embed /OUT:debug\project.exe #C:\Users\user\AppData\Local\Temp\project.exe.125924.1109.jom
LINK : fatal error LNK1117: syntax error in option 'VERSION:.'
jom: C:\Users\user\QtProjects\project\_x64d\Makefile.Debug [debug\project.exe] Error 1117
jom: C:\Users\user\QtProjects\project\_x64d\Makefile [debug] Error 2
20:03:55: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited with code 2.
Error while building/deploying project project (kit: Desktop Qt 5.15.2 MSVC2019 64bit)
When executing step "Make"
20:03:55: Elapsed time: 00:02.
I am following this tutorial on setting up gdnative.
I have installed c++ tools through visual studio, python 3.2, and scons 4.1.0
I am stuck trying to get scons to build this gdnative example. The issue I'm having appears to be scons not being able to find #include files. I have tried using a relative file paths to a sub directory godot-cpp/, relative paths to a sibling directory ../godot-cpp/, and using a full path to the sibling directory E:/Projects/Godot Projects/Units/godot-cpp/ but I am getting the same error every time. I have provided a screenshot to show the file structure. I am running scons from X64 Native Tools Command Prompt for VS 2019
Edit - have now also tried while running as administrator, same error
Top Left: The project I am trying to build and the cpp files I need to include in sibling directories.
Top Right: The contents of the project folder. The godot-cpp/ subdirectory is a copy of the folder of the same name from the Top Left.
Bottom Left: Contents of godot-cpp/
Bottom Right: Contents of godot-cpp/godot-headers. The highlighted file is the one it can't seem to find.
Relative path to sub directory:
E:\Projects\Godot Projects\Units\gdnative_cpp_example>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /I. /Igodot-cpp\godot_headers /Igodot-cpp\include /Igodot-cpp\include\core /Igodot-cpp\include\gen /Isrc
gdexample.cpp
godot-cpp\include\core\Godot.hpp(7): fatal error C1083: Cannot open include file: 'gdnative_api_struct.gen.h': No such file or directory
scons: *** [src\gdexample.obj] Error 2
scons: building terminated because of errors.
Relative path to sibling directory:
E:\Projects\Godot Projects\Units\gdnative_cpp_example>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /I. "/IE:\Projects\Godot Projects\Units\godot-cpp\godot_headers" "/IE:\Projects\Godot Projects\Units\godot-cpp\include" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\core" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\gen" /Isrc
gdexample.cpp
E:\Projects\Godot Projects\Units\godot-cpp\include\core\Godot.hpp(7): fatal error C1083: Cannot open include file: 'gdnative_api_struct.gen.h': No such file or directory
scons: *** [src\gdexample.obj] Error 2
scons: building terminated because of errors.
Full path to sibling directory:
E:\Projects\Godot Projects\Units\gdnative_cpp_example>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /I. "/IE:\Projects\Godot Projects\Units\godot-cpp\godot_headers" "/IE:\Projects\Godot Projects\Units\godot-cpp\include" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\core" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\gen" /Isrc
gdexample.cpp
E:\Projects\Godot Projects\Units\godot-cpp\include\core\Godot.hpp(7): fatal error C1083: Cannot open include file: 'gdnative_api_struct.gen.h': No such file or directory
scons: *** [src\gdexample.obj] Error 2
scons: building terminated because of errors.
It's getting stuck following the include statement from Godot.hpp line 7 to gdnative_api_struct.gen.h. It looks like it can resolve the path just fine but it can't open them for some reason.
SConstruct file - Came with the project I'm trying to build. Only modification was changing the paths to godot-cpp/ and godot-cpp/headers/.
#!python
import os, subprocess
opts = Variables([], ARGUMENTS)
# Gets the standard flags CC, CCX, etc.
env = DefaultEnvironment()
# Define our options
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/'))
opts.Add(PathVariable('target_name', 'The library name.', 'libgdexample', PathVariable.PathAccept))
# Local dependency paths, adapt them to your setup
# These next two lines are where I changed the paths <-----------------
godot_headers_path = "../godot-cpp/godot_headers/"
cpp_bindings_path = "../godot-cpp/"
cpp_library = "libgodot-cpp"
# only support 64 at this time..
bits = 64
# Updates the environment with the option variables.
opts.Update(env)
# Process some arguments
if env['use_llvm']:
env['CC'] = 'clang'
env['CXX'] = 'clang++'
if env['p'] != '':
env['platform'] = env['p']
if env['platform'] == '':
print("No valid target platform selected.")
quit();
# Check our platform specifics
# I'm using windows so I cut the other options for readability
if env['platform'] == "windows":
env['target_path'] += 'win64/'
cpp_library += '.windows'
# This makes sure to keep the session environment variables on windows,
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
env.Append(ENV = os.environ)
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
else:
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
if env['target'] in ('debug', 'd'):
cpp_library += '.debug'
else:
cpp_library += '.release'
cpp_library += '.' + str(bits)
# make sure our binding library is properly includes
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
env.Append(LIBPATH=[cpp_bindings_path + 'bin/'])
env.Append(LIBS=[cpp_library])
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=['src/'])
sources = Glob('src/*.cpp')
library = env.SharedLibrary(target=env['target_path'] + env['target_name'], source=sources)
Default(library)
# Generates help for the -h scons option.
Help(opts.GenerateHelpText(env))
I had this exact same problem today. On the line you changed in your SConstruct file you reference the godot headers directory (the one which contains gdnative_api_struct.gen.h) as godot_headers, but in your file system this folder is called godot-headers (- not _). Because of this scons cannot find the file. Changing the directory's name in the file system to godot_headers solved the problem for me.
I cannot compile 7zip under MSVC2012.
When i type:
C:\7zsrc> nmake NEW_COMPILER=1 MY_STATIC_LINK=1 Build.mak
I get this:
Microsoft (R) Program Maintenance Utility Version 11.00.50727.1
Copyright (C) Microsoft Corporation. All rights reserved.
link -nologo -OPT:REF -OPT:ICF /LARGEADDRESSAWARE -out:O\ oleaut32.li
b ole32.lib user32.lib advapi32.lib shell32.lib
LINK : fatal error LNK1104: cannot open file 'O\'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
\VC\BIN\link.EXE"' : return code '0x450'
Stop.
What should i do to compile it? i tried checking in google but i didn't found anything related to this problem...
Also, here's Build.mak from 7zip souce package:
LIBS = $(LIBS) oleaut32.lib ole32.lib
!IFDEF CPU
!IFNDEF NO_BUFFEROVERFLOWU
LIBS = $(LIBS) bufferoverflowU.lib
!ENDIF
!ENDIF
!IFNDEF O
!IFDEF CPU
O=$(CPU)
!ELSE
O=O
!ENDIF
!ENDIF
!IF "$(CPU)" == "AMD64"
MY_ML = ml64 -Dx64
!ELSEIF "$(CPU)" == "ARM"
MY_ML = armasm
!ELSE
MY_ML = ml
!ENDIF
!IFDEF UNDER_CE
RFLAGS = $(RFLAGS) -dUNDER_CE
!IFDEF MY_CONSOLE
LFLAGS = $(LFLAGS) /ENTRY:mainACRTStartup
!ENDIF
!ELSE
!IFNDEF NEW_COMPILER
LFLAGS = $(LFLAGS)
!ENDIF
CFLAGS = $(CFLAGS) -Gr
LIBS = $(LIBS) user32.lib advapi32.lib shell32.lib
!ENDIF
!IF "$(CPU)" == "ARM"
COMPL_ASM = $(MY_ML) $** $O/$(*B).obj
!ELSE
COMPL_ASM = $(MY_ML) -c -Fo$O/ $**
!ENDIF
CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -WX -EHsc -Gy -GR-
!IFDEF MY_STATIC_LINK
!IFNDEF MY_SINGLE_THREAD
CFLAGS = $(CFLAGS) -MT
!ENDIF
!ELSE
CFLAGS = $(CFLAGS) -MD
!ENDIF
!IFDEF NEW_COMPILER
CFLAGS = $(CFLAGS) -W4 -GS- -Zc:forScope
!ELSE
CFLAGS = $(CFLAGS) -W3
!ENDIF
CFLAGS_O1 = $(CFLAGS) -O1
CFLAGS_O2 = $(CFLAGS) -O2
LFLAGS = $(LFLAGS) -nologo -OPT:REF -OPT:ICF
!IFNDEF UNDER_CE
LFLAGS = $(LFLAGS) /LARGEADDRESSAWARE
!ENDIF
!IFDEF DEF_FILE
LFLAGS = $(LFLAGS) -DLL -DEF:$(DEF_FILE)
!ENDIF
PROGPATH = $O\$(PROG)
COMPL_O1 = $(CC) $(CFLAGS_O1) $**
COMPL_O2 = $(CC) $(CFLAGS_O2) $**
COMPL_PCH = $(CC) $(CFLAGS_O1) -Yc"StdAfx.h" -Fp$O/a.pch $**
COMPL = $(CC) $(CFLAGS_O1) -Yu"StdAfx.h" -Fp$O/a.pch $**
all: $(PROGPATH)
clean:
-del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch
$O:
if not exist "$O" mkdir "$O"
$(PROGPATH): $O $(OBJS) $(DEF_FILE)
link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)
!IFNDEF NO_DEFAULT_RES
$O\resource.res: $(*B).rc
rc $(RFLAGS) -fo$# $**
!ENDIF
$O\StdAfx.obj: $(*B).cpp
$(COMPL_PCH)
Brian Wilson's guide shows how to do this. The guide is for VS2010, but it worked fine for me in VS2012.
The main steps:
Set up the environment variables using "c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\vsvars32.bat"
Edit C:\7zsrc\CPP\Build.mak to remove "-OPT:NOWIN98" from line 34
Run C:\7zsrc\CPP\7zip\nmake NEW_COMPILER=1 MY_STATIC_LINK=1
Note the third step targets the makefile in the 7zip subdirectory instead of the Build.mak that you are targeting.
A number of executable are created. You may be interested in C:\7zsrc\CPP\7zip\UI\Client7z\O\7z.exe
You must compile some "makefile" instead.
I'm looking at adding pre-compiled headers to our scons project. I followed this post http://chadaustin.me/2009/05/unintrusive-precompiled-headers-pch/ and came up with
if ARGUMENTS.get('PRECOMPILED', 'FALSE') == 'TRUE':
PCH, PCH_OBJ = env.PCH('precompiled.cpp')
env['PCH'] = PCH
env['PCHSTOP'] = 'precompiled.h'
env.Append(CPPFLAGS=['/FI' + 'precompiled.h'])
The '/FI' means I don't need to manually add precompiled.h to each .cpp file.
But... I'm getting a warning for each .obj file
warning LNK4206: precompiled type information not found;
'xxx.obj' not linked or overwritten; linking object as if no debug info
which I can't seem to figure out.
I'm not clear on the Microsoft documentation for this warning. http://msdn.microsoft.com/en-us/library/cf1aswwe.aspx
The given object file, compiled with /Yc, was either not specified in the LINK command or was overwritten.
How would I resolve this?
A common scenario for this warning is when the .obj that was compiled with /Yc is in a library, and where there are no symbol references to that .obj from your code. In that case, the linker will not use (or even see) the .obj file. In this situation, you should recompile your code and use /Yl for the remaining objects (the objects that are not compiled with /Yc).
I don't think this is my problem but maybe?
scons run the following command line to create the pdb
i.e. env['PCHCOM']
'$CXX /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
Which expands to
i.e. env.subst(env['PCHCOM'])
'cl /Fo /TP /EHsc /nologo /errorReport:prompt /W3 /EHsc /Z7 /MD /O2 /FIprecompiled.h /DNDEBUG /D_UNICODE /DUNICODE /DWIN32 /DCSFUNIFIED_EXPORTS /DUNIFIED_DLL /IC /I: /I\ /ID /Ie /Iv /Ie /Il /Io /Ip /Im /Ie /In
/It /I\ /Is /Iy /Is /It /Ie /Im /Is /Ie /Ir /Iv /Ii /Ic /Ie /I\ /Id
/Ie /Ip /Ie /In /Id /Ie /In /Ic /Ii /Ie /Is /I\ /Ip /Ir /Ie /Ic /Io /Im /Ip /Ii /Il /Ie /Id /c /Ycprecompiled.h /Fp'
Update
Adding information requested by GaryO
Note I've since updated the code to
if ARGUMENTS.get('PRECOMPILED', 'FALSE') == 'TRUE':
PCH, PCH_OBJ = env.PCH('precompiled.cpp')
env['PCH'] = PCH
env['PCHSTOP'] = 'precompiled.h'
env.Append(CPPFLAGS=['/FI' + 'precompiled.h'])
env.Append(LIBS = PCH_OBJ)
in an attempt to resolve the warning.
The command to create the pre-compiled header
cl /Fodependencies\precompiled\precompiled.obj /TP /EHsc /nologo /errorReport:prompt /W3 /EHsc /Z7 /MD /O2 /FIprecompiled.h /DNDEBUG /D_UNICODE /DUNICODE /DWIN32 /Idependencies\precompiled /c dependencies\precompiled\precompiled.cpp /Ycprecompiled.h /Fpdependencies\precompiled\precompiled.pch
Here is the link command
link /nologo /DEBUG /OPT:REF /OPT:ICF /DEBUG /dll /out:out\windows-x86-MD-unicode-vs2008-rel\bin\csflogger.dll /implib:out\windows-x86-MD-unicode-vs2008-rel\bin\csflogger.lib dependencies\precompiled\precompiled.obj out\windows-x86-MD-unicode-vs2008-rel\bin\apr-1.lib out\windows-x86-MD-unicode-vs2008-rel\bin\aprutil-1.lib out\windows-x86-MD-unicode-vs2008-rel\bin\log4cxx.lib ws2_32.lib DnsAPI.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib psapi.lib out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\CSFLog.obj out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\VersionInfo.obj out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\logger_utils.obj out\windows-x86-MD-unicode-vs2008-rel\obj-shared\dependencies\csflogger\src\main\CSFLogger.obj
On the initial build this does not produce a warning. However if I then modify the project (e.g. comment out a line in precomipled.h) I get the above warning. i.e. Even though the link command is the same.
By adding
env.Append(LIBS = PCH_OBJ)
I thought I was fixing the issue. i.e. Because the .obj should be found. This can be seen in the link command
dependencies\precompiled\precompiled.obj
But it does not fix anything :(.
For completeness here is the command used to compile with the pre-compiled header
cl /Foout\windows-x86-MD-unicode-vs2008-rel\obj-shared\src\framework\SystemServiceDependencyInjector.obj /c src\framework\SystemServiceDependencyInjector.cpp /TP /EHsc /nologo /errorReport:prompt /W3 /EHsc /Z7 /MD /O2 /FIprecompiled.h -W3 -WX /wd4250 /wd4251 /DNDEBUG /D_UNICODE /DUNICODE /DWIN32 /DCSFUNIFIED_EXPORTS /DUNIFIED_DLL /DUSE_TR1_SMART_PTR /DUSE_TR1_SMART_PTR /DWIN32 /DCSFUNIFIED_EXPORTS /DUNIFIED_DLL /Idependencies\precompiled /Iinclude /Iapi /Itestutils /Idependencies\boost /Idependencies\csf2g-foundation\include\portability /Idependencies\csf2g-foundation\include\deprecated /Idependencies\csf2g-foundation\include /Idependencies\csflogger\include /Idependencies\log4cxx\include /Idependencies\libxml2\include /Idependencies\libcurl\include /Idependencies\libcurl\windows\include /Idependencies\ciscossl\releaseTempCiscoSSLTopFolder\inc32 /Idependencies\csf2g-idm\include /Idependencies\jcfcoreutils\include /Idependencies\httpdownloader\include /Idependencies\servicesframework\include /Idependencies\servicesframework\api /Idependencies\configservice-api /Idependencies\csf2g-foundation\include\dnsutils /Idependencies\csf2g-uc-service-locator\include /Idependencies\ucm9-config\include /Idependencies\ucm9-config\src /Idependencies\ucm9-config\src\dns /Idependencies\configservice\include /Idependencies\configservice\api /Idependencies\csfnetutils\include /Yuprecompiled.h "/Fpdependencies\precompiled\precompiled.pch"
Again its the same for the scenario with & without the warning.
That last expansion looks extremely suspect. All those
/I: /I\ /ID /Ie /Iv /Ie /Il /Io /Ip /Im /Ie /In /It /I\ /Is /Iy /Is /It /Ie /Im /Is /Ie /Ir /Iv /Ii /Ic /Ie /I\ /Id /Ie /Ip /Ie /In /Id /Ie /In /Ic /Ii /Ie /Is /I\ /Ip /Ir /Ie /Ic /Io /Im /Ip /Ii /Il /Ie /Id
look like a string being interpreted by python as a list (as it will try to do). Does one of your vars expand to :\Development\systemservice\dependencies\precompiled ? (I just got that by reading the last char of each of those args above) If so, put that into a list or tuple and it should help.
If that doesn't fix it: since the error is coming from the linker, please show the linker command that actually gets run, as well as the compile command for one of the objs that shows up in the error messages.
In the end it seems that
env.Append(LIBS = PCH_OBJ)
did indeed resolve this warning. However if I changed the pre-compiled header itself it would re-appear. The only way I found of resolving this was to do a clean. After that the warning disappeared (until I modified the pre-compiled header again).
I am a little new to the whole makefile concept so I have some questions regarding it.
I am creating a project using CodeBlocks in linux, I used a tool called cbp2mak to create a .make file out of the CodeBlocks project (if anyone knows a better tool please let me know).
Now I am not sure what the difference is between .mak and .makefile, could anyone tell me? I can compile .mak using "make -C .mak" but what is the difference?
The reason im trying to use it is because I want provide the source code for my project and want it to be buildable in both linux and windows so I don't want to give them my codeblocks project file. So i thought I could use a makefile that can be used to build in both linux and windows.
I would also like to check in Windows if both MinGW and VC++ compiler exists and build the source with both compilers, in Linux it will be only with GNU GCC.
The .mak file also has some macros to determine what to build depending on if it is being run on windows or linux as there are platform specific files.
So questions:
-What is the difference between .mak and .makefile
-Can I run a .mak file in windows? say using visual studio?
-Could there be a better solution to what I am doing now? (I used cpb2mak as it automatically generates a .mak file which saves a lot of time as I don't know how to create makefiles)
Also feel free to provide any advice or tips regarding this.
EDIT:
I have now put up the full .mak file
Also my project is a library which I build both a static and shared versions of it. The .mak file was auto generated but I hadded the platform handle with the ifdef and "shell, uname" function
# project performer-1.0
export PATH := /opt/wx/2.8/bin:$(PATH)
export LD_LIBRARY_PATH := /opt/wx/2.8/lib:$(LD_LIBRARY_PATH)
_WX = /home/gr/projects/gui/codeblocks/wx
_WX.LIB = $(_WX)/lib
_WX.INCLUDE = $(_WX)/include
_CB = /home/gr/projects/gui/codeblocks/cb/src
_CB.INCLUDE = $(_CB)/include
_CB.LIB = $(_CB)/devel
CFLAGS_C = $(filter-out -include "sdk.h",$(CFLAGS))
# -----------------------------------------
# MAKE_DEP = -MMD -MT $# -MF $(#:.o=.d)
CFLAGS = -Wall
INCLUDES = -I../performer-1.0
LDFLAGS = -s
RCFLAGS =
LDLIBS = $(T_LDLIBS) -lrt -lboost_regex-gcc43-mt -lxerces-c -lstdc++
LINK_exe = gcc -o $# $^ $(LDFLAGS) $(LDLIBS)
LINK_con = gcc -o $# $^ $(LDFLAGS) $(LDLIBS)
LINK_dll = gcc -o $# $^ $(LDFLAGS) $(LDLIBS) -shared
LINK_lib = rm -f $# && ar rcs $# $^
COMPILE_c = gcc $(CFLAGS_C) -o $# -c $< $(MAKEDEP) $(INCLUDES)
COMPILE_cpp = g++ $(CFLAGS) -o $# -c $< $(MAKEDEP) $(INCLUDES)
COMPILE_rc = windres $(RCFLAGS) -J rc -O coff -i $< -o $# -I$(dir $<)
%.o : %.c ; $(COMPILE_c)
%.o : %.cpp ; $(COMPILE_cpp)
%.o : %.cxx ; $(COMPILE_cpp)
%.o : %.rc ; $(COMPILE_rc)
.SUFFIXES: .o .d .c .cpp .cxx .rc
all: all.before all.targets all.after
all.before :
-
all.after : $(FIRST_TARGET)
# -----------------------------------------------------------
ifeq "$(shell uname)" "Linux"
# -----------------------------------------------------------
all.targets : Linux_Dynamic_target Linux_Static_target
# -----------------------------------------------------------
else
# -----------------------------------------------------------
all.targets : Windows_Dynamic_target
# -----------------------------------------------------------
endif
# -----------------------------------------------------------
clean :
rm -fv $(clean.OBJ)
rm -fv $(DEP_FILES)
.PHONY: all clean distclean
# -----------------------------------------------------------
ifeq "$(shell uname)" "Linux"
# -----------------------------------------------------------
# -----------------------------------------
# Linux_Dynamic_target
Linux_Dynamic_target.BIN = libs/libperformer-1.so
Linux_Dynamic_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/linux/linfactory.o src/data_collection/linux/linmemprof.o src/data_collection/linux/lintimer.o src/data_collection/linux/procsmaps.o src/data_collection/linux/procstatus.o src/data_collection/pstructs.o src/data_collection/resultxml.o
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/linux/linfactory.d src/data_collection/linux/linmemprof.d src/data_collection/linux/lintimer.d src/data_collection/linux/procsmaps.d src/data_collection/linux/procstatus.d src/data_collection/pstructs.d src/data_collection/resultxml.d
clean.OBJ += $(Linux_Dynamic_target.BIN) $(Linux_Dynamic_target.OBJ)
Linux_Dynamic_target : Linux_Dynamic_target.before $(Linux_Dynamic_target.BIN) Linux_Dynamic_target.after_always
Linux_Dynamic_target : CFLAGS += -Wall -g -Os
Linux_Dynamic_target : INCLUDES +=
Linux_Dynamic_target : RCFLAGS +=
Linux_Dynamic_target : LDFLAGS += $(CREATE_LIB) $(CREATE_DEF)
Linux_Dynamic_target : T_LDLIBS =
ifdef LMAKE
Linux_Dynamic_target : CFLAGS -= -O1 -O2 -g -pipe
endif
Linux_Dynamic_target.before :
Linux_Dynamic_target.after_always : $(Linux_Dynamic_target.BIN)
$(Linux_Dynamic_target.BIN) : $(Linux_Dynamic_target.OBJ)
$(LINK_dll)
# -----------------------------------------
# Linux_Static_target
Linux_Static_target.BIN = libs/libperformer-1.a
Linux_Static_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/linux/linfactory.o src/data_collection/linux/linmemprof.o src/data_collection/linux/lintimer.o src/data_collection/linux/procsmaps.o src/data_collection/linux/procstatus.o src/data_collection/pstructs.o src/data_collection/resultxml.o
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/linux/linfactory.d src/data_collection/linux/linmemprof.d src/data_collection/linux/lintimer.d src/data_collection/linux/procsmaps.d src/data_collection/linux/procstatus.d src/data_collection/pstructs.d src/data_collection/resultxml.d
clean.OBJ += $(Linux_Static_target.BIN) $(Linux_Static_target.OBJ)
Linux_Static_target : Linux_Static_target.before $(Linux_Static_target.BIN) Linux_Static_target.after_always
Linux_Static_target : CFLAGS += -Wall -g -Os
Linux_Static_target : INCLUDES +=
Linux_Static_target : RCFLAGS +=
Linux_Static_target : LDFLAGS += $(CREATE_DEF)
Linux_Static_target : T_LDLIBS =
ifdef LMAKE
Linux_Static_target : CFLAGS -= -O1 -O2 -g -pipe
endif
Linux_Static_target.before :
Linux_Static_target.after_always : $(Linux_Static_target.BIN)
$(Linux_Static_target.BIN) : $(Linux_Static_target.OBJ)
$(LINK_lib)
# -----------------------------------------
# -----------------------------------------------------------
else
# -----------------------------------------------------------
# -----------------------------------------
# Windows_Dynamic_target
Windows_Dynamic_target.BIN = libs/performer-1.so
Windows_Dynamic_target.OBJ = src/analysis/analyzer.o src/analysis/comparer.o src/analysis/paverage.o src/analysis/pfunctor.o src/analysis/pmax.o src/analysis/pmin.o src/config/configfile.o src/data_collection/datacollector.o src/data_collection/pstructs.o src/data_collection/resultxml.o src/data_collection/windows/winfactory.o src/data_collection/windows/wintimer.o
DEP_FILES += src/analysis/analyzer.d src/analysis/comparer.d src/analysis/paverage.d src/analysis/pfunctor.d src/analysis/pmax.d src/analysis/pmin.d src/config/configfile.d src/data_collection/datacollector.d src/data_collection/pstructs.d src/data_collection/resultxml.d src/data_collection/windows/winfactory.d src/data_collection/windows/wintimer.d
clean.OBJ += $(Windows_Dynamic_target.BIN) $(Windows_Dynamic_target.OBJ)
Windows_Dynamic_target : Windows_Dynamic_target.before $(Windows_Dynamic_target.BIN) Windows_Dynamic_target.after_always
Windows_Dynamic_target : CFLAGS += -Wall -g -Os
Windows_Dynamic_target : INCLUDES +=
Windows_Dynamic_target : RCFLAGS +=
Windows_Dynamic_target : LDFLAGS += $(CREATE_LIB) $(CREATE_DEF)
Windows_Dynamic_target : T_LDLIBS =
ifdef LMAKE
Windows_Dynamic_target : CFLAGS -= -O1 -O2 -g -pipe
endif
Windows_Dynamic_target.before :
Windows_Dynamic_target.after_always : $(Windows_Dynamic_target.BIN)
$(Windows_Dynamic_target.BIN) : $(Windows_Dynamic_target.OBJ)
$(LINK_dll)
ifdef MAKE_DEP
-include $(DEP_FILES)
endif
# -----------------------------------------------------------
endif
#
I beleive Glen's answer is incorrect as mak and mk (make) files are not at all the same. They are both used in automating builds but that's where the similarity ends.
mak file is a microsoft standard which can be built with the following command out of a visual studio command prompt:
nmake /f NAMEOFfile.mak
nmake is part of Visual Studio and the mak file's synthax/structure will also differ from mk (make) files.
Make or mk files are mainly used in Linux builds with some instances of Cross Platform support (provided that the Dev is supporting Windows). To build mk file you need either Autotools or CMake (these tools are available in both Windows and Linux). mk files will also be accompanied with a configure script that needs to be run before the make step which is not the case for mak/nmake.
I don't think there is a difference. It's just a makefile by a different name.
Try editing your question and posting up the contents of the .mak file and it'll be clearer to us then