Cmake : /bigobj: No such file or directory [duplicate] - c++

This question already has answers here:
GCC equivalent of MS's /bigobj
(5 answers)
Closed 1 year ago.
When I was building an application of mine which used Assimp, I got an error
C:\Users\nitin\AppData\Local\Temp\ccA4Vs3q.s: Assembler messages:
C:\Users\nitin\AppData\Local\Temp\ccA4Vs3q.s: Fatal error: can't write 117 bytes to section .text of CMakeFiles\assimp.dir\AssetLib\IFC\IFCReaderGen1_2x3.cpp.obj because: 'File too big'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/as.exe: CMakeFiles\assimp.dir\AssetLib\IFC\IFCReaderGen1_2x3.cpp.obj: too many sections (46774)
C:\Users\nitin\AppData\Local\Temp\ccA4Vs3q.s: Fatal error: can't close CMakeFiles\assimp.dir\AssetLib\IFC\IFCReaderGen1_2x3.cpp.obj: File too big
Nade\vendor\assimp\code\CMakeFiles\assimp.dir\build.make:1965: recipe for target 'Nade/vendor/assimp/code/CMakeFiles/assimp.dir/AssetLib/IFC/IFCReaderGen1_2x3.cpp.obj' failed
So I searched online for solutions and I found a solution that said that I need to set the /bigobj flag.
I am using Cmake and Mingw32-make.
But when I add the definition like this
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} /bigobj)
or like that
add_definitions(/bigobj)
I Get the error
/bigobj: No such file or directory
How do I solve this error while solving the Too Big OBJ file error at the same time?

The /bigobj option is for Microsoft Visual Studio compiler.
For GCC, try -Wa,-mbig-obj instead.
If you want to support both, try:
if (MSVC)
add_compile_options(/bigobj)
else ()
add_compile_options(-Wa,-mbig-obj)
endif ()
If you want to specify directly only a single target:
target_compile_options(my_target_name PRIVATE /bigobj)

Related

(Clang Error) compilation error: ld: library not found for -lcrt0.o. Any ideas?

The full terminal output is as follows:
>g++ -std=c++98 -static mainP1.o -o mainP1
>
>ld: library not found for -lcrt0.o
>
>clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
>make: *** [mainP1] Error 1
I'm on a 2020 MacBook Pro with an intel CPU using Visual Studio Code. When I write basic OOP programs in C++ it compiles fine without any clang errors. However, when working with big OOP programs with multiple classes inheriting from a base class I would get this error.
I tried searching online for solutions, but no solution or explanation was found. I double-checked my makefile to ensure I was not linking classes incorrectly.
I thought maybe I should just dual-boot with UBUNTU Linux to avoid this weird XCODE issue I was encountering with clang, but that was also a fruitless endeavor.
The problem was my compiler path in Visual Studio Code.
I changed it to clang++, and now all my code compiles and executes without any problems.
How I changed it:
CMD + SHIFT + P
Typed in: C/C++: Edit Configurations (UI)
Made sure that "Mac" was selected under configuration name.
Changed Compiler Path to: /usr/bin/clang++

CMake fails on Mac [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am running a C++ program to test code in my C++ project. I have successfully run it using Eclipse. However, when I try to build it using CMake (for automated testing) it hits the following issue:
The cmake command resolves without problems, but when I run make, it fails with errors of the following three categories:
In file included from /Users/douglas/Desktop/automatedTesting/src/main.cpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:641:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61:
In file included from /Users/douglas/Desktop/automatedTesting/src/string.h:6:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:139:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/streambuf:139:5: error:
unknown type name 'locale'
Along with ‘locale’ the same issue occurs with ‘streamsize’
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/streambuf:155:41: error:
incomplete type 'std::__1::ios_base' named in nested name specifier
And lastly:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:98:24: note:
forward declaration of 'std::__1::ios_base'
These errors are repeated multiple times until a total of 20 are generated, at which point it gives the following final output:
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/makeTest.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/makeTest.dir/all] Error 2
make: *** [all] Error 2
My CMakeLists.txt is the following:
cmake_minimum_required (VERSION 2.6)
project(makeTest)
set (makeTest_VERSION_MAJOR 1)
set (makeTest_VERSION_MINOR 0)
add_executable(makeTest src/main.cpp serial-messenger/forTest.cpp src/String.cpp src/parson.c)
target_include_directories(makeTest PRIVATE src)
target_include_directories(makeTest PRIVATE serial-messenger)
Environment details:
OS: Mac OS High Sierra version 10.13.4
CMake: 3.13.0
CLANG: Apple LLVM version 9.1.0 (clang-902.0.39.2)
XCode is installed
I'm sure I must have made some error with setting up the environment for CMake, but I have no idea what it might be.
Edit: it looks like since Macs are case insensitive, it is mistaking my String.h file for string.h, causing the problem.
Edit 2: The problem was indeed due to Mac being case insensitive. Running it on a case sensitive OS like Linux resolves the issue.
Never give a standard name to a header with custom functionality!
Changing only a case (lower to upper or vice versa) isn't a good idea too.
According to the include chain in the error message, the system header file
.../usr/include/c++/v1/cstring
actually includes a custom one
.../automatedTesting/src/string.h
This is because you give a standard name string.h to your custom header. (Well, the actual name of the file is String.h, but MacOS uses a case-insensitive filesystem). And this is a real problem: the system header expects to obtain some standard definitions with such include, but the custom header doesn't provide them.
Rename your custom header to the non-standard name (e.g., mystring.h) and adjust your #include directives accordingly.

Library not found for -lfl

I was using flex and bison to build a simple calculator project I cloned from Github.
But after I typed make in terminal, I got the following message:
gcc -o calc calc.tab.c lex.yy.c -lfl
calc.y:48:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main() {
^~~~
1 warning generated.
ld: library not found for -lfl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [calc] Error 1
How could I resolve this problem?
let me guess, trying to use flex on OS/X?
Try -ll instead of -lfl
Using Flex on OS/X
So yea, the flex library name on OS/X is just arbitrarily different for some reason. OS/X is not exactly Linux, but it's pretty close. You have some options here.
You can just simply have a separate build system and source files for OS/X. Certainly Apple might like that with their pushing XCode, objective-C and not much interoperability.
You can build vs Linux and then engage with Mac Ports and Homebrew.
You can create your project using autotools. That's not an awesome link, learning this system is rough going, but it's a standard thing for Linux for sure. This will actually work, I find if you have the patience for it, OS/X is close enough that autotools based builds will work on it.
Lately, I've been turned on to Cocoapods, which I believe to be an attempt to join the open source community and XCode. It's kind of half 1 and 3 sorta with an emphasis on modularizing the external source and getting it compiled into a .app (via Xcode).
warning: type specifier missing, defaults to 'int'
mean that you should declare return type for main function. Place int in function difinition.
ld: library not found for -lfl
flag -l mean that compiller must use libfl.a to build programm. As #waTeim said above, for Mac OS you can use libl.a instead, but this lib can be not exist alse. There is another way is to place
%option noyywrap
at the top of flex *.l file. In this case you can compile without additional libs.

Having trouble compiling the Twilio C++ libraries

Compiling the C++ API for Twilio. The instructions by Laurent Luce are not very clear and were done two years ago.
HOW exactly do I use libcurl and openssl with make (nmake) to compile the library???? When I try to run nmake on the command line in the twilio++ directory, I get:
makefile(25) : fatal error U1001: syntax error : illegal character '^'
in macro Stop.
If anyone can help or give directions I would be very relieved
If this error is caused by $^. you may try to replace it with $**. But no guarantees. In general, nmake does not work with GNU makefiles. For best results use GNU make.

How to reproduce #include_next compile time error? [duplicate]

This question already has answers here:
Error compiling OpenCV, fatal error: stdlib.h: No such file or directory
(5 answers)
Closed 2 years ago.
I have a library that could be compile on windows, And now i need to compile on WSL (Debian 9.5). But i get a confusing compile error:
/usr/include/c++/6/cstdlib:74:15
#include_next <stdlib.h>
No such file or directory.
I try to change INCLUDEPATH variable (which i use QMake) but that make no sens. And i couldn't reproduce this error message on another project. How this could be happened ? and how could fix it ?
Specification:
- OS: Debian 9.5 on WSL (Windows 10)
- Compiler: GCC 6.3.0
- C++ Standard: C++17
- Include Paths: /usr/include | /usr/local/include | /usr/include/c++/6/
I think the answer is on another answer here.
Which is to disable precompiled headers.
-DENABLE_PRECOMPILED_HEADERS=OFF