I want to use boost in my Xcode project.(Xcode version 4.3.2)
I had build the boost from the MacPorts, and made the environment variables set.
But when I build the prj, there was the error:
Unknown type name 'namespace'
and the error code below:
// This file is automatically generated. Do not edit.
// ['../../libs/compatibility/generate_cpp_c_headers.py']
// Wed Jul 23 12:11:19 2003 ('GMTST', 'GMTST')
#ifndef __CSTDDEF_HEADER
#define __CSTDDEF_HEADER
#include <stddef.h>
namespace std {
using ::ptrdiff_t;
using ::size_t;
}
#endif // CSTDDEF_HEADER
the auto generated code is C++, not Objective-C.
Objective-C compiler rejects the invalid keyword 'namespace'.
To make it work change you project settings as follows:
- go to you Project Settings and choose the Target
- select Build Settings -> Apple LLVM compiler X.X - Language -> Compile Sources As and set it to Objective-C++ which allows mixture of Objective-C and C++.
Related
I am using Visual Studio 2017 to build LucenePlusPlus which in turn uses boost/dynamic_bitset.
The following code in LucenePlusPlus
const uint64_t* BitSet::getBits() {
return bitSet.empty() ? NULL : static_cast<const uint64_t*>(&bitSet.m_bits[0]);
}
generates the following fatal compiler error:
1>g:\luceneplusplus\src\core\util\bitset.cpp(20): error C2248: 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>::m_bits': cannot access private member declared in class 'boost::dynamic_bitset<uint64_t,std::allocator<Block>>'
1> with
1> [
1> Block=uint64_t
1> ]
Suggestions?
I have traced the code for my boost 1_75_0 and I see it has a define to conditionally reserve access to friends:
#if defined(BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS)
#define BOOST_DYNAMIC_BITSET_PRIVATE public
#else
#define BOOST_DYNAMIC_BITSET_PRIVATE private
#endif
So it looks like you should be able to add -DBOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS to the compiler defines to fix this.
In fact, my LucenePlusPlus tree already contains it in
include/config_h/Config.h.in line 107:
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
Previously ("rebuilt cmake buildsystem") this apparently
came from include/Config.h.cmake, where it was always present, unconditionally all the way since 2010:
What Can You Do?
Maybe you are not including the required headers that include the config? Also check any interfering precompiled header settings.
If you have boost/dynamic_bitset.hpp included BEFORE including LucenePlusPlus headers at any point you will run with the wrong config.
This is especially bad if you don't detect it because that would violate the ODR rule
I am using Windows 10 64-bit machine with Visual Studio Professional 2013 and I want to install SystemC. I downloaded SystemC 2.3.1 and I tried following the "Installation notes" provided but they're slightly outdated.
For one, it says "for VS 2005 and higher on Windows 7 machines" but I am using Windows 10, nevertheless I still tried to follow it. Second, the inclusion of src and lib files cannot be followed as stated there since this method was changed in VS2013. There seems to be no global setting anymore via Tools->Options->Projects->VCC++ directions tab.
Now, I was able to successfully buiold the SystemC.sln solution. However, when I tried to build an example project I got the following error:
LINK : fatal error LNK1104: cannot open file
'C:\Users\Andrew\Downloads\systemc-2.3.1a\systemc-2.3.1a\msvc80\SystemC\Debug.obj'
Even though I think I've correctly specified the src and lib directories in the project properties.
Can anyone explain how to build SystemC with VS2013 on Windows 10 x64?
Update: if you use CMake with Visual Studio, check Setting up a SystemC project with CMake: undefined reference to `sc_core
Currently I have no MSVC2013 installed, so here are steps for MSVC2017 that worked for me.
Download latest SystemC from http://accellera.org/downloads/standards/systemc
Open systemc-2.3.1a\msvc80\SystemC\SystemC.sln in Visual Studio
Visual Studio will offer to update solution, click ok. You can ignore report with warnings.
In VS menu bar set configuration to “Debug“ “Win32”. (In my case was already selected by default)
Build solution (F7)
In console, you may find messages like:
Unknown compiler version - please run the configure tests and report the results
You can ignore them. Solution should build without errors:
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
As a result you will have SystemC.lib in systemc-2.3.1a\msvc80\SystemC\Debug
Now you can create some test SystemC project.
File->New -> Project -> Win32 Console application
Right click on project in solution explorer -> Properties
In Configuration Properties -> C/C++ -> General-> Additional include directories
Add path to: \systemc-2.3.1a\src
In Configuration Properties -> C/C++ -> Code generation -> Runtime Library
Select: Multi-threaded Debug (/MTd)
In Configuration Properties -> C/C++ -> Language -> Enable Run-Time Type Information
Select: Yes (/GR)
In Configuration Properties -> C/C++ -> Command Line -> Additional options
Type: /vmg
In Configuration Properties -> Linker -> General -> Additional Library Directories
Add path to: systemc-2.3.1a\msvc80\SystemC\Debug
In Configuration Properties -> Linker -> Input -> Additional dependencies
Add: SystemC.lib
Now it's time to type some code. For example this "Hello world":
#include "stdafx.h"
struct test_module : sc_module {
SC_HAS_PROCESS(test_module);
test_module(::sc_core::sc_module_name) {
SC_THREAD(test_thread);
}
sc_signal<std::string> message{ "message" };
void test_thread() {
message.write("Hello world!");
wait(1, SC_NS);
cout << message.read() << endl;
sc_stop();
}
};
int sc_main(int argc, char** argv)
{
test_module tmod{ "tmod" };
sc_start();
return 0;
}
In stdafx.h add:
#include <systemc.h>
Build project, it will fail with:
\systemc-2.3.1a\src\systemc.h(120): error C2039: 'gets': is not a member of 'std'
gets was removed from std namespace in latest MSVCs, but it is not really required.
So just open systemc.h and comment out Line 120:
// using std::gets;
In case you got error about sprintf
Add _CRT_SECURE_NO_WARNINGS to list of preprocessor definitions
Build again. Run without debugging (Ctrl+F5). You should see the following introduction test on your console:
SystemC 2.3.1-Accellera --- Feb 1 2017 14:43:06
Copyright (c) 1996-2014 by all Contributors,
ALL RIGHTS RESERVED
Hello world!
Info: /OSCI/SystemC: Simulation stopped by user.
Press any key to continue . . .
Hope that helps
I am trying to include the following PostgreSQL headers files into my Xcode 7.2 project:
#import "postgres.h"
#import "pg_type.h"
#import "libpq-fe.h"
The app is written in Swift. I have an Objective-C bridging header. If I just import "libpq-fe.h" there are no compile errors.
When I try to import "postgres.h" and "pg_types.h" to get access to certain constants, I get an error with a PostgreSQL file: "c.h"
"Typedef redefinition with different types ('size_t' (aka 'unsigned long') vs 'long')
The previous definition is in OS X 10.11 > user/include > MacTypes.h
So there are two headers with the same definition:
PostgreSQL c.h
typedef size_t Size
OSX MacTypes.h
typedef long Size
If I comment out the definition in the PostgreSQL file then the project compiles. But I would rather not have to do that.
Does anyone know a way around this?
I read somewhere about using a 'backend header' but so far I have not been able to figure this out.
Thanks in advance.
I have been trying to get GTK 3.0 to work, and have followed all the steps here
How to configure gtk on Visual studio 2010
And changing to 3.0 where needed to get GTK to work, and it seems to have loaded everything it needs in order to compile, but it gives me the error
Error 3 error LNK1104: cannot open file 'gtk-3.lib'
Whenever I try to run the program.
I am using visual studios 2012, but this was the only place i found anything about getting GTK to run on any visual studios.
Here is the code I am using:
#include <gtk-3.0\gtk\gtk.h>
int main(int argc, char* argv[])
{
gtk_init(&argc, &argv);
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//gtk_widget_get_preferred_size(window, 300, 200);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
gtk_window_set_title(GTK_WINDOW(window), "GTK+ with VS2010");
gtk_widget_show(window);
gtk_main();
return 0;
}
I commented out the gtk_widget_get_prefered_size call because it is irrelevant to the problem
any suggestions? I've looked in several places but none came up with clear answers.
The library gtk-3.lib does not exist. In fact, the library reference is not required to build your GTK 3 application. The pkg-config helper doesn't seem to generate the correct linker flags needed to link your application.
Just add in your Additional Options area all the existing libraries found in your GTK package (\gtk3\lib). The lib files for my bundle (gtk+-bundle_3.6.4-20130921) were as follows:
atk-1.0.lib cairo.lib fontconfig.lib gailutil.lib gdk-win32-3.0.lib gdk_pixbuf-2.0.lib gio-2.0.lib glib-2.0.lib gmodule-2.0.lib gobject-2.0.lib gthread-2.0.lib gtk-win32-3.0.lib pango-1.0.lib pangocairo-1.0.lib pangoft2-1.0.lib pangowin32-1.0.lib
(or you can go to your library path via a command prompt and enter dir *.lib /B)
Don't forget to include the /ENTRY:mainCRTStartup flag mention in the initial answer you started with.
you may have to edit your project settings or use a pragma comment to link with your gtk library:
#pragma comment(lib, "gtk-3")//if the libray is on your project's path
#define PATH "C:\\example\\"
#pragma comment(lib, PATH"gtk-3")//if the library is on PATH
I'm not able to compile clang(3.3) using MinGW 4.8.1. The following error always pops-up when 70% build is complete:
clang/lib/Basic/FileManager.cpp includes sys/stat.h, which defines #define stat _stat64i32 (actually there are a few other defines in between, but you get the idea ;)
clang/include/clang/Basic/FileManager.h does not include sys/stat.h; instead only has a forward-declaration.
Hence, while parsing the header, the forward declaration is used (struct stat)
But when it finally arrives at the implementation, the preprocessor will kick in and replace struct stat with struct stat64i32. Hence the mismatch.
The best solution would be to change the forward declaration in the header to instead include sys/stat.h. (I didn't actually test if it will compile then)
The current trunk does not contain the code anymore.
Update: regarding off64_t. This is defined in _mingw_off_t.h these days as:
#ifndef _OFF64_T_DEFINED
#define _OFF64_T_DEFINED
__MINGW_EXTENSION typedef long long _off64_t;
#if !defined(NO_OLDNAMES) || defined(_POSIX)
__MINGW_EXTENSION typedef long long off64_t;
#endif
#endif /*_OFF64_T_DEFINED */
So you probably want to define _POSIX before including io.h (or stdio.h)