gpt4 book ai didi

c - 如何在 QuickTime SDK for Windows 中使用 CoreFoundation?

转载 作者:太空宇宙 更新时间:2023-11-04 04:05:17 25 4
gpt4 key购买 nike

有人可以帮我在 Cygwin/MingW/VS20(05|08|10) 中编译这段代码吗?
事实上,我想在 QuickTime SDK 7.3 for Windows 中使用 CoreFoundation Framework。

#include <stdio.h>
#include <CoreFoundation.h>

int main () {
CFStringRef hello = CFSTR("Hello, world.");
return 0;
}

我在 Cygwin/MingW 中使用这个 MakeFile 来编译它,但是我得到一个错误:(

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

无忧无虑的警告信息;)

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

在 VisualStudio 2010 中,我得到同样的错误:

LNK2019: unresolved external symbol __imp____CFStringMakeConstantString referenced in function _main

我下载了 Cocotron/CFLite/OpenCFLite 但我还没有 t been to compile this Projects or use that :(
please help me... i
我很努力!

谢谢大家的帮助。

我的英语很差,对此我感到很抱歉。

最佳答案

是的!!!
我终于成功了!
您可以将 CoreFoundation.dll 静态添加到 LDFLAGS MakeFile。 (如果你的系统中安装了 iTunes,你可以在“program files/common files/apple...”中找到这个文件)
我编译这段代码容易多了!

#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;
}


已编辑且没有问题的 makefile:

CC = gcc
LDFLAGS = "CoreFoundation.dll"
CFLAGS = -ICIncludes

all: StringExample.c
$(CC) $(CFLAGS) $(LDFLAGS) -o StringExample StringExample.c -static


祝你好运!

关于c - 如何在 QuickTime SDK for Windows 中使用 CoreFoundation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6711167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com