Code::Blocks & WxWidgets Matching Release configuration - codeblocks

I am attempting to start a new project in Code:: Blocks (v17.12) using WxWidgets (v3.1.3) on Windows (10).
(For context, I am new to compiling- I'm a script coder trying to branch out. So... don't be afraid to talk to me like I'm an idiot. I'm prepared to accept that possibility.)
I downloaded the official 3.1.3 source, expanded it to "D:\code\wxw"
I successfully compiled it using mingw32-make that came with Code::Blocks-- there is a directory "D:\code\wxw\build\msw\gcc_mswudll" and "D:\code\wxw\lib\gcc_dll", the latter containing .dll files.
So I go into code blocks, and I:
Create New Project -> wxWidgets Project
Select wxWidgets 3.1.x
Project Title "HelloWorld", under D:\code\C++\tinker-- everything else autofilled.
Project details-- my info.
Preferred GUI Builder - None. Application Type - Dialog.
wxWidgets' location: D:\code\wxw
Compiler: GNU GCC
Selected "Create Release Configuration" because that's how it was compiled.
It provides an Output dir of "bin\Release\" and an Objects output dir of "obj\Release\", which I do not change.
Selected use DLL, built as monolithic, and enable Unicode-- the latter matching my compile settings.
When I click next, it tells me "A Matching Release configuration cannot be found in the wxWidgets directory you specified. This means that the Release target of your project will not build."
I've found multiple hits searching on this error message, but they all devolve into discussions of monolithic vs polylithic compiling and critique of other compiler settings and not actually addressing the problem.
EDIT:
Based on http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef
I used the following settings for compiling. I set them in config.gcc
BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CXXFLAGS=-fno-keep-inline-dllexport

The most important page of the wizard is the 8th page. Based on the settings you gave above, it should look exactly like this:
Also, instead of giving the path on the 6th page, I would define a global variable named wx in codeblocks like this:
Then on the 6th page, you would enter $(#wx) instead of the actual path. This will make using your projects much easier if you ever upgrade the wxWidgets library. You'll only need to change the location in the global variable settings.

Related

How can I force Xcode to use a custom compiler?

I want to force Xcode to use a custom compiler ('clang-llvm' build from the src) so I can use the clang plugin. My Xcode version is 7.3.1.
People say it is possible with custom toolchains. I didn't make a research on them because easier solution worked well for me:
It is also possible to run frontend plugins directly by setting appropriate "build settings" of Xcode. (Several ways to do this, you can set them on the command line for instance: xcodebuild build FOO=bla.) Here are a few build settings that I found useful to inject C flags:
OTHER_CFLAGS, OTHER_CPLUSPLUSFLAGS or to replace the compiler(s) and linker(s):
CC, CPLUSPLUS, LD, LDPLUSPLUS, LIBTOOL
The same approach works to control the "analyze" action: CLANG_ANALYZER_EXEC, CLANG_ANALYZER_OTHER_FLAGS
Disclaimer: some of those build settings are undocumented (afaik). Use at your own risk.
(Taken from [cfe-dev] Compile/refactor iOS Xcode projects)
For me it was enough to define the following User-Defined Settings in Build Settings of Xcode projects:
CC=my-c-compiler
CXX=my-cxx-compiler
LIBTOOL=my-linker-for-static-libraries
If you use CMake, the way to inject your compiler automatically is to use
set_target_properties(your-target PROPERTIES XCODE_ATTRIBUTE_CC "${YOUR_CC}")
set_target_properties(your-target PROPERTIES XCODE_ATTRIBUTE_CXX "${YOUR_CXX}")
Couple of years ago I've written an article that addresses exactly the problem you describe: Creating and using Clang plugin with Xcode
To enable custom clang you need to actually patch internals of Xcode.app itself, it is technically doable but:
it will break when you update Xcode
it will work correctly on your machine
the version of a plugin and your compiler should match, i.e.
they should be compiled using the same tree
So in general it doesn't really scale, so be careful :)
There's a somewhat obscure feature of Xcode where it supports "alternative toolchains". For example, Swift.org provides installable toolchains for Swift built from current sources.
Unfortunately, while Apple's documentation describes how to install and use such alternative toolchains, it doesn't describe how to create them. There are scripts in the Swift source base which build a toolchain and you can look at them to figure out how it's done. They are in https://github.com/apple/swift/tree/master/utils. Start at build-toolchain, which calls build-script and go from there.
Method 1: Change the User Defined settings
Under the project or target Build Settings add the User Defined settings for
CC=/path/to/cc
CXX=/path/to/c++
This is useful if you have a single compiler or linker you want to call, or if you want to call out to a trampoline that decides what to call on the fly.
Method 2: Create a complete custom toolchain via plugin
Using Clang LLVM 1.0.xcplugin as a template (found in the Xcode.app plugins folder), you can modify the plist to point at your own alternative compiler and linker.
This OLLVM on iOS tutorial walks through it.
From project setting go to build setting with target selected. then select All beside the Basic from the top bar. then under build option you can see the compiler option.
Refer below screenshot,
Update :
I think you should refer Using C and C++ in an iOS App with Objective-C++ and this tutorial.

Eclipse CDT, how to make it NOT search for system headers?

I'm porting a C project compiled on linux to an arm platform using Eclipse Luna on Ubuntu 16.04
When I switch from CC=gcc to CC=arm-none-eabi in the Makefile I get a lot of missing headers and that's ok, that's what the porting job is about.
What bothers me is that when I CTRL-click on a symbol Eclipse doesn't open the corresponding file for the arm toolchain. For instance if I CTRL-click on <time.h> it does NOT open:
/media/BUILDS/arm_gcc493/arm-none-eabi/include/time.h
but instead it always reverts to its linux system counterpart, in this case
/usr/include/i386-linux-gnu/time.h
because that's where gcc would look for but I'm compiling with arm-none-eabi-gcc instead!
I don't want Eclipse to do that because debugging gets really confusing. If I have a problem with the header/source I'm actually trying to compile with, I want Eclipse to open me that file and not the default system one. I fiddled with Project Properties and Eclipse Preferences but with no luck.
Even worse, whenever <sys/socket.h> is included I get an error because the arm toolchain does not have socket.h but if I CTRL-click on it Eclipse takes me to /usr/include/i386-linux-gnu/sys/socket.h
I dont' want that, if the header needed for compilation is not there, it's just not there. I don't want Eclipse to show me other stuff, how do I do that?
The project was created importing into the workspace "Existing Code as Makefile Project" under C/C++
Thank you very much
EDIT:
I did the proper thing and started from scratch creating a project for the Cross ARM GCC Toolchain (with the proper plug-in). My mistake was creating a "Linux GCC" Project and pretending that Eclipse understood what I was trying to achieve just by launching a different "make" command. If, however, you can't restart from scratch, the accepted solution instructs you on how to fix the situation manually.
To resolve this situation you need to update the Preprocessor Include Paths, Macros, etc. setting to use your custom-prefix GCC.
To make the change:
Open Project Properties (Right-click on project and choose Properties)
In C/C++ General -> Preprocessor Include Paths, Macros, etc., choose Providers tab
Select CDT GCC Built-in Compiler Settings
Uncheck Use global provider shared between projects
Replace ${COMMAND} with arm-none-eabi-gcc or arm-none-eabi-g++
Alternatively, you can also edit the same setting at the workspace level to affect all the projects in your workspace. Go to Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery tab instead.
Here are some screenshots that may help.
Before:
Project Properties:
After:

How to enter custom GCC compiler option in Build Options

There seem to a variety of questions like this one without any clear solution that is true for Xcode 7 (or even other versions of Xcode).
I have a version of GCC that I'd like Xcode to use when it compiles. It is not the standard GCC but customized for a different platform. I can specify and use this compiler fine in Eclipse, but would rather use Xcode. The Build Options only list LLVM and nothing else. When I try to add via "other" in that section, all I get is this empty popup:
What goes in this box? I would think that it should be no big deal for Xcode to simply use a GCC that I have available at a specific path on my system, but this appears to be quite complex.
Update: Apparently there is a supported mechanism for installing externally-provided tool chains in Xcode that I wasn't aware of. For example, one can download packages from swift.org that install alternative tool chain packages into /Library/Developer/Toolchains or ~/Library/Developer/Toolchains. Once one of those is installed, Xcode has a GUI option to switch the active tool chain.
There was a recent change to the Swift sources to include a script for building one's own custom tool chain from them.
If you view the Quick Help for that build setting (View > Utilities > Show Quick Help Inspector) or configure the build settings view to show setting names instead of titles (Editor > Show Setting Names), you'll see that that setting is GCC_VERSION.
If you look that up in the Build Settings Reference, you find:
GCC_VERSION
Description:
Numeric identifier. Identifies the GCC version to be used to compile
the target’s source files. When the target’s “System C rule” is set to
GCC System Version (instead of a specific version number), this build
setting is not available in Run Script build phases.
Values:
2.95.2
3.1
3.3
4.0
Default value:
GCC system version.
Specified in:
Project Info > Rules > “System C rule.”
Target Info > Rules > “System C rule.”
Affects:
GCC_VERSION_IDENTIFIER.
That's actually a bit out of date. It says it's specified by fiddling with a build rule (not setting) called the "System C rule". You used to change the version there but now there's a direct build setting for it.
Anyway, this probably doesn't help you do what you want to do. I doubt there's any value you could put in there that would do something useful, let alone use a third-party compiler.
However, the explanation does have a hint. It mentions the System C build rule. You could modify the build rules on the Build Rules tab of the target configuration screen. You can find the System C rule and press the button to copy it to your target, which will let you specify a custom script to process C files (including Objective-C and C++).
Implementing such a script is non-trivial. The inputs, expected outputs, and required behavior of the script are not well documented. There are various environment variables available for the use of such a script. Some are the build settings. You'll need to translate the relevant settings into compiler options. For example, translate the CLANG_WARN_BOOL_CONVERSION setting into the corresponding -Wbool-conversion option.
Some of the other environment variables indicate which file you should operate on, such as INPUT_FILE_PATH, INPUT_FILE_NAME, etc.
You need to tell Xcode what file(s) your rule outputs. These can be based on the input environment variables/settings, such as $(OBJECT_FILE_DIR)-$(CURRENT_VARIANT)/$(CURRENT_ARCH)/$(INPUT_FILE_BASE).o.
In general, this is just not something that Xcode makes easy.
Someone wrote a plugin that will allow you to use gcc from Xcode.
http://hamelot.io/programming/add-gcc-compiler-to-xcode-6/
If you have a custom gcc then you would need to change the paths around etc but the plugin should work.

Xcode compiler plugins & native build settings for platforms

I'm coming up against a problem in the creation of an Xcode compiler plugin that appears to be the result of a problem in the way compile lines are generated by Xcode and how some of these options are overridden by the platform SDK.
Upon creating a custom compiler plugin that functions perfectly when building applications for MacOSX. I noticed a problem when building applications for iPhoneOS. The SDK continually complains about an invalid value in the min-iphoneos-version variable, the reason being that this isn't set on the compile command-line. Looking at the iPhoneOS platform SDK for Xcode5 you notice that the setting is defined in the 'Native Build System.xcspec' file (Applications/Xcode.app/Contents/Developer/Platforms/iPhone*.platform/Developer/Library/Xcode/Specifications/). Essentially, from what I can gather, this file is consulted and the -mmin-macosx-version flag is overwritten with this command-line option which results in a valid build for Apple compilers. However, create your own compiler plugin and problem ensue since your new compiler will not be matched by any of the 'Compiler' definitions in the 'Native Build System.xcspec' file.
I can only think of a couple of solutions to this,
rewrite/patch the 'Native Build System.xcspec' file upon installation, resulting in an horrendous solution requiring making unsupportable patches to Apple's build system.
another technique that allows a custom compiler plugin to define options specific for a platform SDK via some matching technique,
if a new .xcspec file is added to a Plugin in the PrivatePlugIns directory as a Resource, do all of these files get parsed upon build-time? if so then it may be possible to add these settings to a file such as,
Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/PrivatePlugIns/iPhoneSimulator Build System Support.xcplugin/Contents/Resources/MyPlugin.xcspec
Has anyone else come up against this 'road-block' (ahem, design problem)?

How can i set what version of a product I'm in Eclipse?

I've created, debugged, and revised a project that I've been working on, but now I want to be able to specify what version of the binary I'm on. I'm using Eclispe-CDT with MinGW to make this project on my local system, so there is no versioning software involved. Does anyone know how to specify this for both Windows and Linux platforms?
On Windows, the idea is to produce a COFF file with the relevant information.
That is done by adding a step to the build, using windres (found also here).
See this thread as an example.
you could add windres via the project properties/Builders as an additional builder and add the generated object file in the C/C++ Build/GCC C++ Linker/Miscellaneous/Other Objects.
Then you
- a) could do a clean build if the resource is changed or
- b) could change the build options (if you have patience) to change to do a clean build every time you save the project.
On Unix, this doesn't seem to be supported in a similar fashion.

Resources