Error while running bjam in Boost Python - c++

I have installed boostpro (boost 1.47) in my system. (Windows 7 32-bit)
when I run bjam command on "C:\Program Files\boost\boost_1_47\libs\python\example" I get the following error
C:\Program Files\boost\boost_1_47\libs\python\example\boost-build.jam attempted
to load the build system by invoking
'boost-build ../../../tools/build/v2 ;'
but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching C:\Program Files\boost\boost_1_47\libs\python\
example\../../../tools/build/v2).
What does this mean? I don't even have tools/build/v2 in my system. How can I fix this?

Instead of fighting with bjam, you could test Scons. One day I was writing an application which was using boost::python and Scons helped me a lot. For me everything was much more simpler.
And here is an example of Sconstruct:
import os, shutil, platform, re
import SCons.Builder
def copyLibBuilder( target, source, env):
'''copy library'''
shutil.copy( str(source[0]), str(target[0]) )
return
env = Environment()
env.Append( ENV = {'PATH' : os.environ['PATH'] })
if(platform.system() == "Linux"):
env.Append( CPPPATH = ['/usr/include/python2.7'] )
env.Append( LIBPATH = ['/usr/lib/python2.7'] )
env.Append( CPPFLAGS = '-Wall -pedantic -pthread -O3 -std=c++0x -lboostpython' )
env.Append( LINKFLAGS = '-Wall -pthread' )
env.Append( LIBS = [ 'boost_python' ] )
elif(platform.system() == "Windows"):
env.Append( CPPPATH = [ Dir('C:/Boost/include/boost-1_52'), # path to installed boost headers
Dir('C:/Python27/include') ] ) # path to installed python headers
env.Append( LIBPATH = [ Dir('C:/Boost/lib'), # path to boost library
Dir('C:/Python27/libs') ] ) #path to python
env.Append( CPPFLAGS = ' /EHsc /MD /D "WIN32" /D "_CONSOLE" /W4' )
env.Append( LINKFLAGS = ' /SUBSYSTEM:WINDOWS ' )
else:
print platform.system() + " not supported"
#build C++ library
cpplib = env.SharedLibrary( target = 'sources',
source = ['file1.cpp', 'file2.cpp'])
if(platform.system() == "Linux"):
target = 'my_new_module.so'
elif(platform.system() == "Windows"):
target = 'my_new_module.pyd'
env.Command(target, cpplib, copyLibBuilder )

Related

I can't properly add external dependency with bazel

I trying to test "Hello World" C++ project with Bazel.
I have the following project structure:
WORKSPACE
/dependencies
BUILD
BUILD.gtest
/test
BUILD
WORKSPACE has the following structure:
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# gtest
http_archive(
name = "gtest",
url = "https://github.com/google/googletest/archive/release-1.10.0.zip",
sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91",
build_file = "#//dependencies:BUILD.gtest",
strip_prefix = "googletest-release-1.10.0",
)
BUILD.gtest has the following structure:
cc_library(
name = "main",
srcs = glob(
["src/*.cc"],
exclude = ["src/gtest-all.cc"]
),
hdrs = glob([
"include/**/*.h",
"src/*.h"
]),
copts = ["-Iexternal/gtest/include"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
test BUILD has the following structure:
cc_test(
name = "unittests",
srcs = ["scanner_test.cc"],
copts = ["-Iexternal/gtest/include"],
deps = [
"//scanner:scanner",
"#gtest//:main"
]
)
when I execute
bazel build //test:unittests
I get
INFO: Analyzed target //test:unittests (26 packages loaded, 315 targets configured).
INFO: Found 1 target...
ERROR: ../test/BUILD:1:8: Compiling test/scanner_test.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 25 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
test/scanner_test.cc:1:10: fatal error: gtest/gtest.h: No such file or directory
1 | #include "gtest/gtest.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
Target //test:unittests failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.314s, Critical Path: 0.08s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
As the other answer mentions:
The file BUILD.gtest is not needed.
Because gtest repo / release archive already provides one.
The reason why your own didn't behave as you might have expected is you've tried to point to the headers by manipulating copts which is applied only to building that one specific cc_library target (from linked docs):
The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere.
Whereas to expose these interfaces to other targets consuming it you need to use includes (docs again):
Unlike COPTS, these flags are added for this rule and every rule that depends on it.
The file BUILD.gtest is not needed.
WORKSPACE.bazel:
workspace(name = "GTestDemo")
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "gtest",
url = "https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
)
BUILD.bazel:
cc_test(
name = "tests",
srcs = ["test.cpp"],
deps = [
"#gtest//:gtest",
"#gtest//:gtest_main",
],
)
test.cpp:
#include <iostream>
#include <fstream>
#include "gtest/gtest.h"
using namespace std;
TEST(sample_test_case, sample_test) {
EXPECT_EQ(1, 1);
}
Tested with Bazel 4.1.0.

scons can't find #include files

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.

OpenCV library not found - cmake with conan

I have a conanfile describing what I want to include (in this case, mainly the OpenCV part), and a corresponding cmakelists going with it. When running conan install and then cmake, it works, but during compilation the OpenCV libraries could not be included. The same code works on windows, so I wonder if I forgot some setting or so.
The include files appear to be found, but when it comes to linking:
`undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)''
Conanfile.py:
from conans import ConanFile, CMake
from conans import tools
from conans.tools import os_info, SystemPackageTool
import os, sys
import sysconfig
from io import StringIO
class PadConan(ConanFile):
name = "AmbuScan"
version = "0.1.0"
description = "AmbuScan for pad localization"
url = ""
license = "GPL"
short_paths = True
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
ubitrack_version = "1.3.0"
requires = (
"opencv/4.3.0#conan/stable",
"kinect-azure-sensor-sdk/1.4.1#camposs/stable",
"zlib/1.2.11#camposs/stable",
)
# all sources are deployed with the package
exports_sources = "include/*", "src/*", "CMakeLists.txt"
def system_requirements(self):
pass
def configure(self):
self.options['opencv'].contrib = False
self.options['opencv'].cuda = False
def imports(self):
self.copy(src="bin", pattern="*.dll", dst="./bin") # Copies all dll files from packages bin folder to my "bin" folder
self.copy(src="", pattern="**.dll", dst="./bin", keep_path=False) # Copies all dll files from packages bin folder to my "bin" folder
self.copy(src="lib", pattern="*.lib", dst="./lib") # Copies all lib files from packages lib folder to my "lib" folder
self.copy(src="bin", pattern="*", dst="./bin") # Copies all applications
self.copy(src="bin", pattern="*.dll", dst="./bin") # Copies all dll files from packages bin folder to my "bin" folder
self.copy(src="lib", pattern="*.dylib*", dst="./lib") # Copies all dylib files from packages lib folder to my "lib" folder
self.copy(src="lib", pattern="*.so*", dst="./lib") # Copies all so files from packages lib folder to my "lib" folder
self.copy(src="lib", pattern="*.a", dst="./lib") # Copies all static libraries from packages lib folder to my "lib" folder
def _configure_cmake(self):
cmake = CMake(self)
cmake.verbose = True
def add_cmake_option(option, value):
var_name = "{}".format(option).upper()
value_str = "{}".format(value)
var_value = "ON" if value_str == 'True' else "OFF" if value_str == 'False' else value_str
cmake.definitions[var_name] = var_value
for option, value in self.options.items():
add_cmake_option(option, value)
cmake.configure()
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake.install()
CMakelists.txt:
cmake_minimum_required(VERSION 3.18)
project(PadLocalizer C CXX)
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo_multi.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo_multi.cmake)
conan_set_find_paths()
elseif(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
else()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif()
conan_basic_setup(TARGETS)
include(GNUInstallDirs)
if(UNIX)
if(APPLE)
MESSAGE(STATUS "Building for Macos.")
set(PAD_TARGET_APPLE 1)
endif()
MESSAGE(STATUS "Building for Unix.")
set(PAD_TARGET_UNIX 1)
elseif(WIN32)
MESSAGE(STATUS "Building for Windows.")
set(PAD_TARGET_WINDOWS 1)
endif()
if (MSVC)
# per default disable extended aligned storage for now on msvc
add_definitions(-D_DISABLE_EXTENDED_ALIGNED_STORAGE -DHAVE_SNPRINTF)
endif()
set(PAD_HEADERS
"include/runtime.h"
)
set(PAD_HEADERS_CAPTURE
"include/azure_camera.h"
)
set(PAD_SOURCES
src/main.cpp
)
set(PAD_SOURCES_CAPTURE
src/azure_camera.cpp
)
source_group(pad\\include FILES ${PAD_HEADERS})
source_group(pad\\include\\capture FILES ${PAD_HEADERS_CAPTURE})
source_group(pad\\src FILES ${PAD_SOURCES})
source_group(pad\\src\\capture FILES ${PAD_SOURCES_CAPTURE})
add_executable(pad
${PAD_SOURCES}
${PAD_HEADERS}
${PAD_SOURCES_CAPTURE}
${PAD_HEADERS_CAPTURE}
)
set_target_properties(pad PROPERTIES CXX_STANDARD 17)
set_target_properties(pad PROPERTIES LINKER_LANGUAGE CXX)
set_property(TARGET pad PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(pad PUBLIC
CONAN_PKG::opencv
CONAN_PKG::eigen
CONAN_PKG::kinect-azure-sensor-sdk
)
target_include_directories(pad PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>/include
$<INSTALL_INTERFACE:include>
PRIVATE
${PROJECT_BINARY_DIR}/include
${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/include
)
# need to review these settings if they are still appropriate
MESSAGE(STATUS "Building for ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
if(WIN32)
set_target_properties(pad PROPERTIES COMPILE_FLAGS "/EHsc /c /W3 /GR /wd4355 /wd4996 /wd4251 /wd4275 /wd4819 /wd4290")
set_target_properties(pad PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS "WIN32" "_MBCS" "BOOST_SPIRIT_USE_OLD_NAMESPACE")
set_target_properties(pad PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib")
## Check for Windows Version ##
if( ${CMAKE_SYSTEM_VERSION} EQUAL 6.1 ) # Windows 7
MESSAGE(STATUS "Setting minimum Windows version to Win7 WINVER=0x0601")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0601)
elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 6.2 ) # Windows 8
MESSAGE(STATUS "Setting minimum Windows version to Win8 WINVER=0x0602")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0602)
elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 6.3 ) # Windows 8.1
MESSAGE(STATUS "Setting minimum Windows version to Win8.1 WINVER=0x0603")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0603)
elseif( ${CMAKE_SYSTEM_VERSION} EQUAL 10.0 ) # Windows 10
MESSAGE(STATUS "Setting minimum Windows version to Win8.1 WINVER=0x0603")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0603)
else() # Some other Windows
MESSAGE(STATUS "Setting minimum Windows version to Vista WINVER=0x0600")
set_target_properties(pad PROPERTIES COMPILE_DEFINITIONS WINVER=0x0600)
endif()
endif(WIN32)
install(TARGETS pad EXPORT padConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # This is for Windows
# This makes the project importable from the install directory
# Put config file in per-project dir (name MUST match), can also
# just go into 'cmake'.
install(EXPORT padConfig DESTINATION share/pad/cmake)
# This makes the project importable from the build directory
export(TARGETS pad FILE padConfig.cmake)
Which OS and compiler do you use? What are your conan settings? Type:
conan profile show default
If "default" is your default profile of course.
If you use compiler gcc > 5, please make sure you use the c++11 ABI:
conan profile update settings.compiler.libcxx=libstdc++11 default
See output of pkg-config opencv --libs to find out what libraries you're missing.
Then add them to your config.

Bazel, Windows 10 toolchain configuration with mingw64 compiler

I need to build my own toolchain with Bazel, and I would like to force Bazel to use the g++ compiler of mingw64. I am following the instruction in https://docs.bazel.build/versions/master/tutorial/cc-toolchain-config.html trying to adapt them to my Windows 10 machine.
Bazel is able to compile my Hello-world.cc and create the hello-world.exe, and if I run
bazel-bin/main/hello-world
I get the right output.
Nevertheless, Bazel throws the following errors:
bazel build --config=mingw64_config -s //main:hello-world --verbose_failures
Starting local Bazel server and connecting to it...
INFO: Analyzed target //main:hello-world (15 packages loaded, 47 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //main:hello-world [action 'Compiling main/hello-world.cc', configuration: e711ec75bfc5b6e1d77ea144cef912e655797b748714c6396a6b8cd3625eebee, execution platform: #local_config_platform//:host]
cd C:/users/_bazel_user/bcge3shs/execroot/__main__
SET PATH=c:\tools\msys64\usr\bin;c:\tools\msys64\bin;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Haskell\bin;C:\Program Files\Haskell Platform\8.6.5\lib\extralibs\bin;C:\Program Files\Haskell Platform\8.6.5\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Haskell Platform\8.6.5\mingw\bin;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin;C:\Users\Documents\Bazel\bazel_binary;C:\mingw64\bin;C:\Users\AppData\Roaming\cabal\bin;C:\Users\AppData\Roaming\local\bin;C:\Users\AppData\Local\Microsoft\WindowsApps;C:\Program Files\LLVM\bin
SET PWD=/proc/self/cwd
SET RUNFILES_MANIFEST_ONLY=1
C:/mingw64/bin/g++ -MD -MF bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.d -frandom-seed=bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.o -iquote . -iquote bazel-out/x64_windows-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/x64_windows-fastbuild/bin/external/bazel_tools -c main/hello-world.cc -o bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.o
SUBCOMMAND: # //main:hello-world [action 'Linking main/hello-world', configuration: e711ec75bfc5b6e1d77ea144cef912e655797b748714c6396a6b8cd3625eebee, execution platform: #local_config_platform//:host]
cd C:/users/_bazel_user/bcge3shs/execroot/__main__
SET PATH=c:\tools\msys64\usr\bin;c:\tools\msys64\bin;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Haskell\bin;C:\Program Files\Haskell Platform\8.6.5\lib\extralibs\bin;C:\Program Files\Haskell Platform\8.6.5\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Haskell Platform\8.6.5\mingw\bin;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin;C:\Users\Documents\Bazel\bazel_binary;C:\mingw64\bin;C:\Users\AppData\Roaming\cabal\bin;C:\Users\AppData\Roaming\local\bin;C:\Users\AppData\Local\Microsoft\WindowsApps;C:\Program Files\LLVM\bin
SET PWD=/proc/self/cwd
SET RUNFILES_MANIFEST_ONLY=1
C:/mingw64/bin/g++ -o bazel-out/x64_windows-fastbuild/bin/main/hello-world bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.o -Wl,-S -lstdc++
ERROR: C:/users/documents/bazel/mingw64__compiler/main/BUILD:3:10: output 'main/hello-world' was not created
ERROR: C:/users/documents/bazel/mingw64__compiler/main/BUILD:3:10: not all outputs were created or valid
Target //main:hello-world failed to build
INFO: Elapsed time: 4.171s, Critical Path: 0.31s
INFO: 2 processes: 2 local.
FAILED: Build did NOT complete successfully
Below is my cc_toolchain_config.bzl:
# NEW
load("#bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
# NEW
load(
"#bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
"flag_group",
"flag_set",
"tool_path",
)
all_link_actions = [ # NEW
ACTION_NAMES.cpp_link_executable,
ACTION_NAMES.cpp_link_dynamic_library,
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
]
def _impl(ctx):
tool_paths = [
tool_path(
name = "gcc",
path = "C:/mingw64/bin/g++",
),
tool_path(
name = "ld",
path = "C:/mingw64/bin/ld",
),
tool_path(
name = "ar",
path = "C:/mingw64/bin/ar",
),
tool_path(
name = "cpp",
path = "C:/mingw64/bin/cpp",
),
tool_path(
name = "gcov",
path = "C:/mingw64/bin/gcov",
),
tool_path(
name = "nm",
path = "C:/mingw64/bin/nm",
),
tool_path(
name = "objdump",
path = "C:/mingw64/bin/objdump",
),
tool_path(
name = "strip",
path = "C:/mingw64/bin/strip",
),
]
features = [ # NEW
feature(
name = "default_linker_flags",
enabled = True,
flag_sets = [
flag_set(
actions = all_link_actions,
flag_groups = ([
flag_group(
flags = [
"-lstdc++",
],
),
]),
),
],
),
]
return cc_common.create_cc_toolchain_config_info(
ctx = ctx,
features = features, # NEW
cxx_builtin_include_directories = [
"C:/mingw64/include",
"C:/mingw64/x86_64-w64-mingw32/include",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0/include-fixed",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0/include",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0",
],
toolchain_identifier = "local",
host_system_name = "local",
target_system_name = "local",
target_cpu = "x64_windows",
target_libc = "unknown",
compiler = "g++",
abi_version = "unknown",
abi_libc_version = "unknown",
tool_paths = tool_paths,
)
cc_toolchain_config = rule(
implementation = _impl,
attrs = {},
provides = [CcToolchainConfigInfo],
Any suggestions on what the problem could be?
The answer to this question can be found here:
Mingw-w64 toolchain for Bazel (Ubuntu 20.04.1 )
It is sufficient to load: artifact_name_pattern from #bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl and set artifact_name_patterns attribute of cc_common.create_cc_toolchain_config_info():
artifact_name_patterns = [
artifact_name_pattern(
category_name = "executable",
prefix = "",
extension = ".exe",
),]

eclipse: can't change C/C++ build settings (for adding gprof)

I want to analyze a C++ code in eclipse with GPROF.
I added the code that I want to analyze with "new -> Makefile Project with Existing Code" because I got it as open source from the Internet and now I want to profile it. I'm working with gprof and with eclipse for the first time.
My problem is, that when I go to "project -> properties -> C/C++ build -> settings" I don't see anything more than "Binary Parsers" and "Error Parsers". I can't add flags (e.g. -pg) for the Compiler and Linker. It might have something to do with the Makefile Project?!
(Unfortunately I can't add my screenshot because of to less reputation).
How can I use gprof now? Can I add flags to Compiler and Linker somewhere else?
Thank you!
aciams
EDIT:
The Makefile has been created with cmake. So I added -pg to every file that does not begin with "# CMAKE generated file: DO NOT EDIT!".
When I build the project again I find -pg in
# compile CXX with /usr/bin/c++
CXX_FLAGS = -O3 -DNDEBUG -Wall -g -pg
but when I run the program and search for a file named "gmon.out" nothing can be found. Do I have to set -pg to the Linker explicitly?
This is the important part of CMakeLists.txt:
project()
#set ( CMAKE_BUILD_TYPE Debug )
set ( CMAKE_BUILD_TYPE Release )
#set ( CMAKE_CXX_COMPILER "icpc" )
#set ( CMAKE_CXX_COMPILER "g++-4.2" )
add_definitions ( -Wall -g -pg)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(${CMAKE_CXX_COMPILER} MATCHES "icpc")
set ( OPENMP_FLAG "-openmp" )
set ( OPENMP_LINK "-openmp" )
else()
set ( OPENMP_FLAG "-fopenmp" )
set ( OPENMP_LINK "-lgomp" )
endif(${CMAKE_CXX_COMPILER} MATCHES "icpc")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(${CMAKE_GENERATOR} MATCHES "Makefile")
find_package ( OpenMP REQUIRED )
set ( OPENMP_FLAG "-fopenmp" )
set ( OPENMP_LINK "-lgomp" )
#set ( APP_TYPE MACOSX_BUNDLE )
else()
set ( OPENMP_FLAG "-fopenmp" )
set ( OPENMP_LINK "" )
endif(${CMAKE_GENERATOR} MATCHES "Makefile")
else()
set ( OPENMP_FLAG "" )
set ( OPENMP_LINK "" )
endif()
set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set ( CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH}
/sw
/opt
/opt/local
/Users/$ENV{USER}/Development
./include
./lib
)
include ( ${QT_USE_FILE} )
include_directories (
${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
set ( EXECUTABLE_OUTPUT_PATH build/release )
set_source_files_properties ( test.cpp test2.cpp
PROPERTIES COMPILE_FLAGS ${OPENMP_FLAG}
)
add_executable ( )
target_link_libraries ()
install ( )
Thanks!