What is TARGET_API_MAC_CARBON? - macos-carbon

I am new to Objective-C and OS X development. I see this in some code I'm trying to get to work:
#include <Carbon/Carbon.h>
#if ! TARGET_API_MAC_CARBON
#include <OSA.h>
#include <AppleScript.h>
#include <Gestalt.h>
#endif
#include <string.h>
when is TARGET_API_MAC_CARBON defined? Wikipedia says carbon is the old API. I don't see a "TARGET_API_MAC_COCOA" or anything. I only need the code to work on Mac OS X 10.9.

Carbon should be defined if you're linking the Carbon framework (which you're almost certainly not doing). It's the legacy technology that was used to bridge MacOS apps between "Classic MacOS" (i.e. MacOS 7, 8, 9) and today's MacOS 10.X releases.
That said, I have to wonder about the code you're trying to link in. How old is it? Gestalt, for example, is pretty fully deprecated at this point.

Related

Build Issues after Upgrading app from vs2005 to vs2012

I need my application to be upgraded from visual studio 2005 IDE to visual studio 2012 .
The upgradation wizard converts the solution and project files successfully with 0 errors and few warnings.
But when i start building the application i get error message :
error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended. in atlcore.h !
I tried changing the version no to 0x0500 , 0x0501 , 0x0502 and also 0x0601 ( both through /D compiler option and manually changing in atlcore.h , WINVER is also changed. ) but no luck . the same error is being displayed.
Where do i go wrong ?
Visual C++ no longer supports targeting Windows 95, Windows 98, Windows ME, or Windows NT. If your WINVER or _WIN32_WINNT macros are assigned to one of these versions of Windows, you must modify the macros.
To modify the macros, in a header file, add the following lines.
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
EDIT:
WINVER determines the minimum platform SDK required to build your application, which in turn will determine at compile time which routines are found by the headers.
#define _WIN32_WINNT_NT4 0x0400
#define _WIN32_WINNT_WIN2K 0x0500
#define _WIN32_WINNT_WINXP 0x0501
#define _WIN32_WINNT_WS03 0x0502
#define _WIN32_WINNT_WIN6 0x0600
#define _WIN32_WINNT_VISTA 0x0600
#define _WIN32_WINNT_WS08 0x0600
#define _WIN32_WINNT_LONGHORN 0x0600
#define _WIN32_WINNT_WIN7 0x0601
Other Solution:
If you have installed a WIndows SDK on your PC (in /Microsoft SDKs/Windows), you can #include in stdafx.h (or in a header you include in all your C++ files). Including SDKDDKVer.h will target the highest Windows version available.
Hopefully It work!!!!!
For more info SEE HERE
Problem temporarily solved by commenting a check in atlcore.h :
if _WIN32_WINNT > 0x0501
//#error This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.
endif
I know it isnt the right way to do [ editing a file shipped by the IDE ] but did since it may be due to Improper installation.
If anyone come across a permanent fix let me know .
you can add a pre-processor directive for the project under project settings, C/C++, Pre-processor definitions, appending WINVER=0x0501;
(you can also undefine definitions)
I'm wondering if you are using pre-compiled headers which is overwriting changes to stdafx.h, this is the way to make sure this is set
This preprocessor setting holds until code in the project files changes it, at which point if this doesn't fix the problem, then you must find how or where this is being set/unset/checked; but the solutions shouldn't involve any changes to the windows SDK files

Inquiry: Integrating libsndfile with Visual Studio 2010 C++. Error: libsndfile.dll not found

I am teaching myself how to read in wav files into C++ as a part of me learning C++. I have found many resources online that recommended the following library: libsnfile library
So I followed some tutorials below in testing the basic functionality of the library, but I can't get the library to compile with Visual Studio 2010.
I have searched online for the following error, but did not find anything useful for my particular error. I downloaded the libsndfile C++ windows installer found here. I used the 32bit version since I am using the win32 C++ console version. However, my Visual Studio is 64 bit. I did the following after I downloaded the installer:
I went into Visual Studio. Under my project, I did the following:
In project properties:
1. VC++
Include >> added ...\libsnfile\include
Library >> added ...\libsnfile\lib
2. C\C++
Added the following directory as additional dependencies
...\libsnfile\lib\libsndfile-1.lib
I did this to add this third party library to my project. After this, to test, I ran the following code:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>
int _tmain(int argc, _TCHAR* argv[])
{
printf("This is a test\n");
getchar();
return 0;
}
I coded that to make sure that I could access the sndfile.h in my program and everything compiled. The problem occured when I tried to implement the following code:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>
int _tmain(int argc, _TCHAR* argv[])
{
printf("This is a test\n");
//This will be the length of the buffer used to hold samples while the program processes them.
//A SNDFILE is like FILE in a standard C library. Consequently, the sf_open_read and sf_open_write functions will return an
//SNDFILE* pointer when they successfully open the specified file.
SNDFILE* sf = NULL;
/*SF_INFO will obtain information of the file we wish to load into our program. */
SF_INFO info;
/*This is where the program will open the WAV file */
info.format = 0;
sf = sf_open("C:\Users\GeekyOmega\Desktop\gameon.wav", SFM_READ, &info);
if(sf == NULL)
{
printf("Failed to open the file.\n");
exit(-1);
}
getchar();
return 0;
}
I then get a system error when I click run inside visual studio when I try to run my program. It says,
The program can't start because libsnfile-1.dll is missing from your computer.
Try reinstalling the program to fix this problem.`
I tried the 64 bit windows installer and tried that, but it didn't work. Anyone understand what I am doing run? I am running Visual Studio's 2010 on Windows 7 as my dev environment.
I apologize if I am making a silly mistake, but I would deeply appreciate if anyone could help me. I tried a few hacky fixes, as I talked about above, but nothing has worked.
EDIT: I am also aware of this thread here, but this doesn't make any sense to my current issue as I am not doing any of this path stuff that they are talking about.
Warm Regards,
GeekyOmega
I fixed the issue. For future readers, this is a very common problem, I think. I placed the .dll in the debug folder of my Visual Studio project. Visual Studio couldn't see the .dll file otherwise. After this, the program fired up as expected and ran. If this does not fix the issue for you, then I suggest something else could be going on.

Where to get iostream.h

I'm trying to make something in Linux, but it complains that it can't find iostream.h. What do I need to install to get this file?
The correct name of this standard header is just iostream without an extension.
If your compiler still cannot find it, try the following:
find /usr/include -name iostream -type f -print
...and add it to your include path, following your compiler's documentation.
The header <iostream.h> is an antiquated header from before C++ became standardized as ISO C++ 1998 (it is from the C++ Annotated Reference Manual). The standard C++ header is <iostream>. There are some minor differences between the two, with the biggest difference being that <iostream> puts the included contents in namespace std, so you have to qualify cin, cout, endl, istream, etc. with "std::". As somewhat of a hack (it is a hack because header files should never contain "using" directives as they completely defeat the purpose of namespaces), you could define "iostream.h" as follows:
#ifndef HEADER_IOSTREAM_H
#define HEADER_IOSTREAM_H
#include <iostream>
using namespace std; // Beware, this completely defeats the whole point of
// having namespaces and could lead to name clashes; on the
// other hand, code that still includes <iostream.h> was
// probably created before namespaces, anyway.
#endif
While this is not exactly identical to the original antiquated header, this should be close enough for most purposes (i.e. there should be either nothing or very few things that you will have to fix).
I needed to compile partport on Debian and had problems (CentOS 4.5 worked fine). I did this without any success:
ln -s /usr/include/c++/4.5/iostream /usr/include/c++/4.5/iostream.h
I discovered that iostream.h was provided from C++, and I found it on CentOS 4.5.
So I copied the file iostream.h from CentOS 4.5 to Ubuntu 11.04 (Natty Narwhal), and it worked:
scp root#ip.centos-4.5:/usr/include/c++/3.3.4/backward/iostream.h /usr/include/c++/4.5/iostream.h

can't get my code to run from a programming book(c++)

i got a new programing book (multicore programming by cameron hughes, tracey hughes).
so far i have not got one of their programs to work their book says that it should work on 99% of computers so im a little confused but at the end of each program in their book they have "compile and link instructions"... do i need to enter that? it looks something like this "C++ -o guess_it guess_it.cc". the code im runnning right now is:
#include <iostream>
#include <windows.h>
#include <string>
#include <spawn.h>
#include <sys/wait.h>
using namespace std;
int main(int argc,char *argv[],char *envp[])
{
pid_t ChildProcess;
pid_t ChildProcess2;
int RetCode1;
int RetCode2;
int Value;
RetCode1 = posix_spawn(&ChildProcess,"find_code",NULL,
NULL,argv,envp);
RetCode2 = posix_spawn(&ChildProcess2,"find_code",NULL,
NULL,argv,envp);
wait(&Value);
wait(&Value);
return(0);
}
im running windows 7(32-bit), AMD athion x2 7550 dual-core proessor, VC++ 2008 Express edition.
i get the following error : fatal error C1083: Cannot open include file: 'spawn.h': No such file or directory
anyone know why i can't get my code to run? do i need to download something? because i read the book and did not see anything about downloading anything but i might be wrong. :(
It looks like that book is using POSIX threading. Visual Studio uses Windows Threading by default, which has a completely different API.
You most likely just need to get a copy of a POSIX Thread library for Windows. That will include spawn.h and the appropriate lib files for you to use.
Forgive me if I'm misreading your level of experience here, but it sounds as though you are a complete beginner with this language.
The example compilation and link instruction in the book
C++ -o guess_it guess_it.cc
is an example of how to invoke a compiler and linker from the command line. If you're using Visaul C++ then the IDE will automate the compilation and link process for you when you click the "build" button, so you don't need to worry about doing this from the command line.
On to the error you're seeing in VC++:
The compiler is telling you that it can't find the header file spawn.h, which you've told it that your program needs in the line
#include <spawn.h>
As other on this page have mentioned, spawn.h is a file supplied by the POSIX standard libraries and contains functionality for spawning new processes.
Respectfully, it sounds to me from the way you asked your question ("compile and link instructions") as though you don't really understand what you're doing. Before you delve into multi-threading in C++, I recommend taking a step back and find a beginner's book on C++ using Visual Studio, and start from the beginning. I'm afraid you'll make very little progress unless you take the time to learn the fundamentals, and using the compiler is about as fundamental as it gets!
Good luck!

Standard Template Library using g++

While migrating a program from windows in linux I encountered a problem using the c++ standard template library. I am trying to typedef a template and I am getting the error 'expected initializer before '<' token on this line
typedef std::list< std::pair< int,double> > PairList;
Any ideas why this would work using mvc++ and not using g++ and how I can fix it?
I think this is about #includes.
The following really minimal piece of code compiles perfectly here with g++ on Linux
#include <utility>
#include <list>
typedef std::list< std::pair< int,double> > PairList;
PairList x;
One thing to remember about standard include files is that they are allowed but not required to call each other. (It's not like they're potentially polluting the namespace by this, since they all use namespace std, which you aren't supposed to mess with.)
It is possible that, in MSVC++, includes , or vice versa, but this is not the case in the g++ headers. Therefore, a program might compile in MSVC++ and not in g++, with a required header missing in the source.
Make sure all of your required headers are actually included, and you should be fine.
Did you #include <utility> for pair?
I have had no problems with the code in G++, and generally found its STL support to be superb. Do you have all the #include directives there? Sometimes those differ from platform to platform (even when they shouldn't).

Resources