Anybody can help me for compile this code in Cygwin / MingW / VS20(05|08|10)?
Indeed i want to use CoreFoundation Framework in QuickTime SDK 7.3 for Windows.
#include <stdio.h>
#include <CoreFoundation.h>
int main () {
CFStringRef hello = CFSTR("Hello, world.");
return 0;
}
i used this MakeFile for compile it, in Cygwin/MingW, but i get an error :(
CC = gcc
LDFLAGS = -L"C:/Program Files/QuickTime SDK/Libraries" -lQTMLClient
CFLAGS = -Wall -mwindows -I"C:/Program Files/QuickTime SDK/CIncludes"
all: StringExample.c
$(CC) $(CFLAGS) $(LDFLAGS) -o StringExample StringExample.c -static
Carefree warning message ;)
StringExample.c: In function 'main':
StringExample.c:5:17: warning: unused variable 'hello' [-Wunused-variable]
C:\Users\censored\AppData\Local\Temp\ccJzEryl.o:StringExample.c:(.text+0x16): undefined reference to `_imp____CFStringMakeConstantString'
collect2: ld returned 1 exit status
make: *** [all] Error 1
In VisualStudio 2010, i get the same error:
LNK2019: unresolved external symbol __imp____CFStringMakeConstantString referenced in function _main
i downloaded the Cocotron/CFLite/OpenCFLite but i havent been to compile this Projects or use that :(
please help me... i
m very tried!
Thanks guys for help me.
My english is very bad, i`m so sorry about this.
YES!!!
I finally succeeded!
You can add CoreFoundation.dll statically to LDFLAGS MakeFile. (if installed itunes in your system, you can find this file on "program files/common files/apple...")
I've Compiled this code so much easier!
#include <stdio.h>
#include <stdlib.h>
#include <CoreFoundation/CoreFoundation.h>
#define BufferSize 1000
void show(CFStringRef formatString, ...) {
CFStringRef resultString;
CFDataRef data;
va_list argList;
va_start(argList, formatString);
resultString = CFStringCreateWithFormatAndArguments(NULL, NULL, formatString, argList);
va_end(argList);
data = CFStringCreateExternalRepresentation(NULL, resultString, CFStringGetSystemEncoding(), '?');
if (data != NULL) {
printf ("%.*s\n\n", (int)CFDataGetLength(data), CFDataGetBytePtr(data));
CFRelease(data);
}
CFRelease(resultString);
}
int main(){
CFMutableStringRef mutStr;
UniChar *myBuffer;
myBuffer = malloc(BufferSize * sizeof(UniChar));
mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(NULL, myBuffer, 0, BufferSize, kCFAllocatorNull);
CFStringAppend(mutStr, CFSTR("eAmin. "));
show(CFSTR("Hello, %@"), mutStr);
CFRelease(mutStr);
free(myBuffer);
return 0;
}
Edited & none problem makefile:
CC = gcc
LDFLAGS = "CoreFoundation.dll"
CFLAGS = -ICIncludes
all: StringExample.c
$(CC) $(CFLAGS) $(LDFLAGS) -o StringExample StringExample.c -static
Good Luck!