eclipse中如何配置jdk在XCODE C++中配置SDL

初三学生的编程之旅!!↖(^ω^)↗
C++ SDL学习之路 1st —— 配置一下SDL
好的,最近我找了一个EasyX图形库的官方群 C语言革命 中的一位管理员,他同意教我SDL哦!
所以这个SDL系列我也是刚开始学,不会像其他系列一样已经会了再写的博客。
现在我已经学会了如何配置SDL,上车吧:
The first step(第一步):
去官网下载SDL2.0,下载完解压即可,这里是地址:
选择下面的SDL2-devel-2.0.5-VC.zip (Visual C++ 32/64-bit)下载
The second step(第二步):
首先,用Visual Studio(也可以是别的IDE,但是我用的是这个)新建一个空项目(控制台项目也可以),然后右键解决方案资源管理器中的项目(项目名称),然后选择属性,如图操作:
The third step(第三步):
接下来选择VC++目录,然后更改包含目录和库目录中的目录位置,分别改成include和lib\x86,前面加你你的SDL2文件夹所在的位置
The fourth step(第四步):
然后展开链接器,选择里面的输入,然后添加 附加依赖项,然后如图操作,在里面添加
SDL2main.lib
The fifth step(第五步):
再找到链接器中的系统,找到第一个 子系统,将里面改为:
控制台 (/SUBSYSTEM:CONSOLE)
The sixth step(第六步):
依次点击“确定”“确定”就可以啦
The seventh step(第七步):
新建一个cpp,名字随意,然后开心的输入(复制吧,骚年)下面的代码:
#include &SDL.h&
#include &stdlib.h&
int main(int argc, char** args)
if (SDL_Init(SDL_INIT_EVERYTHING))
atexit(SDL_Quit);
The eighth step(第八步):
接下来F5一下,如果成功弹出呵呵的控制台窗口并且一闪而过,那么恭喜:你的第一个SDL程序诞生了(SDL配置成功)。
如果报错(如图):
那么就有下面的一步:
The ninth step(第九步,都报错的~):
将SDL2-2.0.5\lib\x86中的SDL2.dll文件复制到你的项目exe同目录中,即 项目名称\Debug中,再运行一下,就会出现第七步的情况:一闪而过,那么恭喜你终于做出了第一个SDL程序
好吧,SDL学习之路1st结完结,撒花,2nd说不定会讲到什么我也不知道的东西,好吧,开玩笑,期待2nd吧!
注:由于此配置十分复杂,若有问题请从此博文回复或者联系QQ
没有更多推荐了,SDL c++ 如何引用class中public_百度知道
SDL c++ 如何引用class中public
比如这个:class A{public:};class B{};在下面B类里该如何引用呢??B::B(){
int c = b -//错误的引用}谢啦~
本人学的是C。不了解C++。但又需要用上C++。麻烦了class Foo{private:/***忽略***/public:
int X, Y;};class Square{private: int Vxf, Vyf , x ,public:/***忽略***/Square::Square(){
Vxf = (X - x)/10;
Vyf = (Y - y)/10;
//请问要使以上这两句有效要怎么改呢??}
我有更好的答案
如果Foo和Square是基类和派生类的关系,就如二楼朋友所说的。不是的话,可以在Square中构造Foo的对象,然后通过对象引用:Square::Square(){
Vxf = (foo.X - x)/10;
Vyf = (foo.Y - y)/10;}
请问这个该怎么改呢??
Foo foo 后面没有分号!!
之前就是加了也不行,所以没加。现在加了之后这样,怎么破??
Foo是不是没有默认构造函数,得为Foo提供三个参数的值,比如:Foo&foo(1,&2,&3);
采纳率:57%
应将类A设为类B的基类
即class B:public A另外 不能定义编译器生成的构造函数 应该在类中声明B()
为您推荐:
其他类似问题
sdl的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。MFC中使用SDL2
[问题点数:40分,无满意结帖,结帖人yztkdqzw]
本版专家分:0
结帖率 100%
CSDN今日推荐
本版专家分:0
结帖率 100%
本版专家分:0
本版专家分:0
本版专家分:0
本版专家分:0
匿名用户不能发表回复!|
CSDN今日推荐macos - C++ SDL on macosx without Xcode - Stack Overflow
to customize your list.
This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our , , and our .
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
System: black Macbook running Mac os X 10.5.5 (Leopard)
I want to compile an SDL hello-world application using only g++. Xcode is good for macintosh but I want cross-platform compatibility, so I won't use any of the coaca framework (no menus, no buttons, etc). Also, porting Xcode projects to other os's is not something that sounds fun. I downloaded and installed SDL into /Library/Frameworks.
The big question is: what goes in the makefile (assuming just a helloWorld.cpp file in the source). I would like to avoid modifying the Helloworld file found
if possible.
1,18331725
Took me a little while to figure this out myself, only I was already using SDL and was transitioning from C to C++ on Lion. Its not just the makefile that is the issue here, its probably your source file as well...
Download SDL-version.tar.gz
Extract and run at prompt
./configure --prefix=/home/user/SDL && make && make install
Assuming everything actually built, you now can use the sdl-config to build your source by executing:
g++ Main.cpp -o Main `/home/user/SDL/sdl-config --cflags --libs` \
-framework OpenGL -framework Cocoa
which is the same as
g++ Main.cpp -o Main -I/home/user/SDL/include \
-L/home/user/SDL/lib -lSDLmain -lSDL -framework OpenGL -framework Cocoa
Now the key here is that you are using C++... for SDL macros to correctly replace your main, you need to prevent the C++ compiler from mangling you main function call. To do this declare your main like the following:
extern "C" int main(int argc, char ** argv)
If you don't include the extern "C" stuff, C++ will change the name of your main function and SDL won't be able to automatically find it. If you don't use the int main(int argc, char ** argv) function signature, C++ will complain about type mismatches... so you've got to do it verbatim. (If using GCC, you exclude the extern "C" portion)
4,43393556
all: helloWorld
helloWorld: helloWorld.o
g++ -o helloWorld helloWorld.o `sdl-config --libs`
helloWorld.o: helloWorld.cpp
g++ -c `sdl-config --cflags` helloWorld.cpp
sdl-config is a tool which should have come with your SDL install that outputs appropriate compiler and linker flags for when compiling with SDL.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Post as a guest
Post as a guest
Post Your Answer
By clicking &Post Your Answer&, you acknowledge that you have read our updated ,
and , and that your continued use of the website is subject to these policies.
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled首先,我知道这个问题已经经被许多,多次,我至少读了五个或者十个变体。 我有底线:helloWorld = SDL_LoadBMP("helloworld.bmp");在我的Xcode 5项目的main.cpp 文件中。 目录结构如下所示:TestProject1
helloworld.bmp
TestProject1.1
TestProject1.xcodeproj当然,我尝试了不同的路径 换句话说,Resources/helloworld.bmp,是的,资源文件夹被导入到项目中。 但是,语句返回 NULL,因为( 根据 SDL_Error ) 找不到文件。 现在,行:helloWorld = SDL_LoadBMP("/fully/qualified/path/to/helloworld.bmp");工作正常,所以我的代码不存在问题。 让Xcode处理资源相对路径的普遍接受的方式是什么? 我正在寻找一个方法,当我做一个更大的项目时,它是可以移植的( 。对于SDL支持的平台,在不同的计算机/设备上进行 ofc ) 。 阅读其他问题后我尝试过的其他事项:添加 helloworld.bmp 以生成阶段& 复制文件。添加代码://----------------------------------------------------------------------------
//This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the. app bundle
#ifdef __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
CFRelease(resourcesURL);
chdir(path);
std::cout &&"Current Path:" &&path &&std::
//----------------------------------------------------------------------------到 main.cpp ( 返回"的开头需要非限定 id"。if (CFURL...) 行中的编译器错误) 。!我说,使用绝对路径,这是有效的,但我想要可移植性。调用 getcwd: 这是 C++ 代码。 有什么我在这里找不到的? 看起来 getcwd 不是 C++ 函数。
时间:17年08月16日原作者:
在 Build Phases 中,你需要创建一个 Copy Files 类型的新构建阶段。设置 Destination 为'资源',除非你想在资源中有子文件夹( 如果有很多字体,纹理,声音等) 。离开 Copy only when installingunticked然后,只需将资源添加到构建阶段,在你然后,你就可以通过执行以下操作来加载:helloWorld = SDL_LoadBMP("helloworld.bmp");或者,如果使用子路径:helloWorld = SDL_LoadBMP("textures/helloworld.bmp");这是你可以将 SDL2.framework 与应用程序捆绑在一起的一种方式。 这里有一个教程 ,第 3部分介绍了如何在你感兴趣的情况下捆绑框架。尽管完全可以移植的构建最好的方式就是类似于or和 Gradle 。
Copyright (C) 2011 HelpLib All rights reserved. &&}

我要回帖

更多关于 idea中如何配置jdk 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信