本文介绍了如何在Windows版QuickTime SDK中使用CoreFoundation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我在Cygwin/MingW/VS20(05 | 08 | 10)中编译此代码吗?
确实,我想在Windows的QuickTime SDK 7.3中使用CoreFoundation框架.

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

我在Cygwin/MingW中使用此MakeFile对其进行编译,但出现错误:(

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

无忧警告消息;)

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中,我得到相同的错误:

In VisualStudio 2010, i get the same error:

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 m!

i downloaded the Cocotron/CFLite/OpenCFLite but i havent been to compile this Projects or use that :(please help me... im very tried!

谢谢大家对我的帮助.

我的英语很不好,对此我感到很抱歉.

My english is very bad, i`m so sorry about this.

推荐答案

是!
我终于成功了!
您可以将CoreFoundation.dll静态添加到LDFLAGS MakeFile. (如果您的系统中安装了iTunes,则可以在程序文件/公共文件/苹果..."上找到此文件)
我已经很容易地编译了这段代码!

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


已编辑&没问题的makefile文件:

Edited & none problem makefile:

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

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


祝你好运!

这篇关于如何在Windows版QuickTime SDK中使用CoreFoundation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 01:14