How do I set unicode as character set in the ALL_BUILD and ZERO_CHECK Visual Studio 2013 projects that are generated by Cmake? - unicode

I am currently using CMake to create a bunch of Visual Studio 2013 projects and it works.
However, the automatically created ZERO_CHECK and ALL_BUILD projects are set to use MBCS by default although I want them to use the Unicode character set.
I did specify the use of the Unicode character set for my projects with the following :
ADD_DEFINITIONS(-DUNICODE)
ADD_DEFINITIONS(-D_UNICODE)
and it worked. I tried to set the c++ compiler flags with something like :
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /UMBCS /D_UNICODE /DUNICODE")
or even :
ADD_DEFINITIONS(-DUNICODE)
ADD_DEFINITIONS(-D_UNICODE)
before my project settings, but it did not affect ZERO_CHECK and ALL_BUILD at all.
Any Ideas ?

You could use cmake --build . -- /p:CharacterSet=Unicode to build your project with Unicode set as characterset.
In fact by this way you pass a parameter to do this to MSBuild itself, not CMake.

I found a solution.
Thanks to Mike, I realized I was searching in the wrong direction.
Since CMake does not give access to the meta-targets (and I can understand why), one must
set up the Visual Studio environment to make MFC compile with MBCS.
This link explains why Microsoft did remove native MBCS support for MFC projects and this link provides a download for the MFC-MBCS package.
I'll remain careful with this because I still want my projects to use Unicode, and I'll use CMake flags accordingly. However, ZERO_PROJECT and ALL_BUILD now compile just fine.
It is Raman Sharma's post that made me finally see the light.
Thanks you guys, you made my day :D
Best regards !
RL

In my case in cmake file CMAKE_MFC_FLAG was set to non-zero value:
if(NOT WIN_HEAPINSPECTOR)
#static link runtime lib
set(CMAKE_MFC_FLAG 1)
elseif()
#dynamic link runtime lib
set(CMAKE_MFC_FLAG 2)
endif()
I changed it to 0 and then it compiled.

ZERO_CHECK and ALL_BUILD are meta-targets. All your projects depend on ZERO_CHECK, all your projects are dependencies of ALL_BUILD, but those two projects themselves do not produce any libraries or executables, thus you need not to care about their build settings.
There could also be other such meta-targets, e.g. INSTALL if you used install() function.

Related

error: unable to spawn process (Argument list too long) in Xcode Build

I am getting this error:
"error: unable to spawn process (Argument list too long)
** ARCHIVE FAILED **
The following build commands failed:
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(1 failure)
Exitcode =65 "
I went through this link:
Xcode export localization throws error "Argument list too long"
This article provides a good temporary solution of the problem stating to reduce the path hierarchy. But this does not seem to be an appropriate approach. Can anyone provide me with a different approach to the solution for this problem?
In my case, it was about custom configurations in .xcconfig files.
My config files were including Pods configurations like:
// Development.xcconfig
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.debug (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.release (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.release (development).xcconfig"
// Production.xcconfig
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.debug (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.release (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.release (production).xcconfig"
This produced the error you mentioned, when I added Firebase pods into my Podfile.
So to make this compile again I had to:
remove all inclusion (#include ...),
set them explicitly in the Project -> Info -> Configuration, as follows:
Quick tip:
If you don't want manually setting up corresponding target configurations (those with red icon), mark them as None and run pod install. This will automatically change it for you.
A few days ago I faced a similar challenge. I want to provide details and share my research with SO community.
First of all I found this thread and I followed the link in the asked question.
And yes, thats right, the answer marked in the link is correct, but the solutions to this problem did not suit me.
Problem
In my case, I had this problem when I changed the folder hierarchy in my project to be more convenient and suitable for me.
#oOEric option did not suit me, because according to the rules, the hierarchy of groups in Xcode should coincide with the hierarchy of folders in the system.
But I've already had about 1680 swift files to compiling.
The problem was that I had too long path to the compiled files and their number was too large.
Research
Then I start research and found swift jira with the same bug.
Here some links:
Main
Linked Issue 1
Linked Issue 2
Linked Issue 3
Bug on Open Radar
But here I didn't find some solutions for me.
Most of all I was pleased with this response of the swift developers.
Again, this is an Xcode-side issue, not a Swift-side issue. Commenting here won't make the Xcode engineers work any faster!
(We're not all the same people at Apple.)
Okey, after this answer, I was finally convinced that if it is an Xcode bug, then the solution should be sought in Xcode.
Solutions
Temporary solution
You need to move your project higher in the hierarchy of your system.
I choose this one, because I have really big project and the use of other solutions will require more than one day from me.
In my case, I conducted an experiment and calculated that the length of the path to the project should be no more than 50 characters.
But this is a temporary solution. If your project grows further, you will have to shorten the path or use other solutions.
Cocoa Touch Framework target
This solution is suitable for files that do not use dependencies.
First of all you need to add Cocoa Touch Framework as a target to you main project.
This target should be added automatically to Embedded Binaries and Linked Framework and Libraries.
After this you need to find some files without dependencies and change target membership to your "TestTarget".
Don't forget classes, properties, methods, enums, protocols from cocoa touch framework should have open or public access.
And don't forget clean your DerivedData folder.
Modular iOS
This solution has a more integrated approach.
If you want to use any dependencies in your Cocoa Touch Frameworks you should go to this guide and make more complex refactoring for your big project!
Link to solution
I think this is the best solution.
I hope this big answer will help someone!
I solved this by setting build system to Legacy build system
in file-> workspace setting -> select workspace setting
I solved this by reducing the hierarchy of groups in Xcode.
e.g. original files at project_name/project_name/About/Model/Text
I removed the groups "Model", "Text" and moved files under project_name/project_name/About/
I made simple script for temporary fix that problem. https://github.com/gregoryvit/flatter
It simply move all swift files in Xcode project to root group.
Error - unable to spawn process (Argument list too long)
There are many reason for this error. Some of these are mentioned below:
Your project might have many swift files (say more than 2000)
Most of the Swift source files may be deeply nested inside directories
Many of these files have absolute paths with more than 150 characters (eg. /Macintosh HD⁩/⁨Users⁩/jayprakashnd⁩/⁨mySampleProject/Module1…)
Xcode swift complier takes the absolute paths of all source files while so compiling, the ARG_MX limit is reached and build fails.
This has been fixed in Xcode 11 wherein a flag is used to set unlimited number of swift files.
Solutions:
Switch to Xcode 11 and add USE_SWIFT_RESPONSE_FILE to YES in build settings - User Defined Section
If you cannot switch to Xcode 11 then take a new checkout of your project in Macintosh HD⁩ ▸ ⁨Users⁩ directory with folder name as minimal as possible.
Solution 2 worked for me like a charm!
It happened to me when I use Xcode 11 beta version using Live Preview. Then I solved it by restarting Xcode after that error has gone.
I have fixed this issue, moving my folder of My Xcode project to the mac root and changing my name Folder to less characters.
Terminal: cd /
Change name folder to BX (example).
xcode11
-build setting
-user-defined
-add setting: USE_SWIFT_RESPONSE_FILE
-setValue: YES
Doing this you enable xcode to have more files than is allowed. But im not sure if this always solve the problem.
I have changed build type to legacy and it also resolved problem for me, both locally and on our CI builder. For me it was caused during checking Podfile.lock and Manifest.lock. Probably this could be skipped in our pipeline since we are always installing pods on CI.
If you faced this issue on your Flutter project while building in Release mode (or Archive) check out my this answer: https://stackoverflow.com/a/61446892/5502121
Long story short:
set your build system to New Build System in File > Project Settings…
remove ios and build_ios folders
run flutter create . to init new ios module
run pod install
run flutter pub get
check your Xcode build config (it should be Release mode and General iOS Device)
and you're good to go
I have the same problem. I fix it using a temporary solution, however that work for me.
My solution is to change the Derived Data folder to a directory with a shorter path.
The Steps is as the following:
Xcode -> File -> Workspace Settings... -> Select Custom Location for Derived Data and give a shorter path as the location.

How can I set up a GTK+ Project in Code::Blocks if gtk doesn't have the right subfolders?

I'm following this tutorial on how to set up a GTK+ project on Code::Blocks 16.01. The link in Step 1 to download GTK+ doesn't work, so I instead did a "Open in Desktop" from the Gtk Github repository. When doing Step 3 and giving the path for the location GTK, I get this error:
The path you entered seems valid, but the wizard can't locate the
include directory. The wizard cannot continue.
When I look back at the repository, I see there is no "include" or "lib" subfolder that is needed to make the project. What can I do to setup the project if neither of those folders exist? I realize the tutorial was written in 2013, so maybe it's outdated. There is a 2015 YouTube tutorial about setting this up, but it seems more complicated with setting up environment variables and changing Code::Blocks "Global Compiler Settings", so I was wondering if this 2013 tutorial still works.
That tutorial has a lot of outdated info in it. It recommends GTK+2, GTK+ is now at version 3, moving on to 4, and you'll probably want to follow GTK's methods for installing and setting up instead of orienting yourself around Code::Blocks.
My recommendation would be to follow the GTK+ download instructions and the instructions on how to set it up and maybe these instructions on how to start, then begin making it work with Code::Blocks (for which you probably need to look at this question).
Also, with how much work it takes to set up Code::Blocks for GTK+3 anyway, you may consider using a different IDE.

Linking Qt Libraries to a Cmake project (in eclipse)

so what I'm trying to do is utilize a simple Qt application IN eclipse without using the eclipse QT plugin by linking the required libraries through the GCC C++ Linker. However, I have been unable to locate the exact name of the library to use, or which libraries will be necessary. I've located the path of the Qt library my application seems to be accessing, but I continue to get an error when building that just says "-lqt" doesn't exist/can't find, etc.
The reason I'm doing this is because I'm building a simple game in OGRE for a project at the uni and wanted to use a Qt application for the GUI. Well, I didn't necessarily want too, but our professor wishes us to do so. Please don't suggest that I simply embed an Ogre widgit into my Qt application as this isn't an opti
Any ideas?
Thanks <3
Well, if you are using CMake then it should take care of everything provided that you instructed it to do so. phb provided a link to even better instructions.
First step is to instruct the CMake that we need Qt for our project. This is done with (you can specify individual parts that are needed as well):
find_package(Qt4 REQUIRED)
If Qt is not found in the typical locations (e.g. QTDIR is not set) - cmake will fail.
You also have to instruct CMake to use Qt include paths and set certain compiler definitions:
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
Finally, for each target you need to tell that you'd like to link with Qt libraries:
target_link_libraries(foo ${QT_LIBRARIES})
You might also want to process your headers and will have to process the user interface files with moc. For the details please refer to the provided links.
In addition to provided links you can have a look at the comments at the top of FindQt4.cmake file.

I can't get qml to use my custom plugin

I'm working in QtQuick and right now struggling with a weird problem: I can't get my custom plugin to work in Qml. There's a simple demo in the SDK (Examples/4.7/declarative/tutorials/extending/chapter6-plugins) and this doesn't work on my computer either. I don't get any error messages except that it doesn't recognize my custom items. Has anybody seen this problem? Any suggestions?
My setup:
Win 7 Home Premium, Qt Creator 2.1.0, Qt 4.7.3 (MinGW 4.4)
Thanks
Beside the qmldir issue already mentioned by blakharaz, also make sure to set QML_IMPORT_PATH in your pro file or setting the path via QDeclarativeEngine::addImportPath() so the module can be found on your development environment (if you don't install them systemwide before using).
And when using subfolders, make sure they are part of the import (see http://doc.qt.nokia.com/4.7-snapshot/qdeclarativemodules.html)
It would be nice to have some code. One possible issue could be the directory structure or the qmldir file. If you want to have a plugin called Foo you basically need a directory Foo which contains the Foo.dll (or libFoo.so) and a qmldir file (content is at least "plugin Foo")
If you have that "import Foo 1.0" should load the library.
I just had the exact same problem.
Build your .dlls as release instead of debug, that fixed it for me.

Architecture in Eclipse

How can I change architecture in Eclipse from x86 to pdp11, what flags do I need, and do I need adjust cross-compiler, thanks in advance
You can't since a PDP-11 is a 16bit computer it can't be equiped with the necessary resources to run eclipse ;-)
EDIT: Sorry that I had the impression that this is somekind of fun question (now I have to give a more serious answer).
Assuming you want to create C code:
You need to download eclipse CDT
and MinGW add the bin directory to you PATH
create a C project and edit the project properties "C/C++ Build" and set the required options for code generation see
GCC PDP Options for options like
-munix-asm
Use Unix assembler syntax. This is the default when configured for
`pdp11-*-bsd'.
-mdec-asm
Use DEC assembler syntax. This is the default when configured for any
PDP-11 target other than
`pdp11-*-bsd'.
Hope this helps. Maybe you need some additional packages for gcc, since I don't believe it comes with PDP features out of the box.