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

发布于 11-23 15:41 字数 1251 浏览 4 评论 0原文

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

#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编译这个项目或使用那个:( 请帮助我...我已经很努力了!

谢谢你们帮助我。

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情愿2024-11-30 15:41:53

是的!!!
我终于成功了!
您可以将 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

祝你好运!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文