Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 1406|回复: 1
打印 上一主题 下一主题

C++ 幫忙!

[复制链接]

23

主题

0

好友

122

积分

高级会员

Rank: 3Rank: 3Rank: 3

跳转到指定楼层
1#
发表于 2011-5-30 03:09 AM |只看该作者 |倒序浏览
當我compile 的時候出現這個信息,請問該怎樣解決

C:\Users\Eric\Desktop\sad\Makefile.win [Build Error]  ["sample] Error 1

Main.cpp
  1. //Main.cpp
  2. #include <iostream>
  3. #include "Socket.h"

  4. using namespace std;

  5. int main()
  6. {
  7.     int choice;
  8.     int port = 666;
  9.     //char *ipAddress = "127.0.0.1";
  10.     string ipAddress;
  11.     bool done = false;
  12.     char recMessage[STRLEN];
  13.     char sendMessage[STRLEN];
  14.     cout<<"1) Host server"<<endl;
  15.     cout<<"2) Join server"<<endl;
  16.     cout<<"3) Quit"<<endl;
  17.     cin>>choice;
  18.     if ( choice == 3 )
  19.         exit(0);
  20.     else if ( choice == 2 )
  21.     {
  22.         //Client
  23.         cout<<"Enter an IP address, 127.0.0.1 is the loopback address"<<endl;
  24.         cin>>ipAddress;
  25.         ClientSocket sockClient;
  26.         cout<<"ATTEMPTING TO CONNECT..."<<endl;
  27.         sockClient.ConnectToServer( ipAddress.c_str(), port );
  28.         //Connected
  29.         while ( !done )
  30.         {     
  31.             sockClient.GetAndSendMessage();
  32.             cout<<"\t--WAIT--"<<endl;
  33.             sockClient.RecvData( recMessage, STRLEN );
  34.             cout<<"Recv > "<<recMessage<<endl;
  35.             if ( strcmp( recMessage, "end" ) == 0 ||
  36.                         strcmp( sendMessage, "end" ) == 0 )
  37.             {
  38.                 done = true;
  39.             }
  40.         }
  41.         sockClient.CloseConnection();
  42.     }
  43.     else if ( choice == 1 )
  44.     {
  45.         //SERVER
  46.         ServerSocket sockServer;
  47.         cout<<"HOSTING..."<<endl;
  48.         sockServer.StartHosting( port );
  49.         //Connected
  50.         while ( !done )
  51.         {
  52.             cout<<"\t--WAIT--"<<endl;
  53.             sockServer.RecvData( recMessage, STRLEN );
  54.             cout<<"Recv > "<<recMessage<<endl;
  55.             sockServer.GetAndSendMessage();
  56.             if ( strcmp( recMessage, "end" ) == 0 ||
  57.                     strcmp( sendMessage, "end" ) == 0 )
  58.             {
  59.                 done = true;
  60.             }
  61.         }
  62.     }
  63. }



  64. Make File
复制代码
  1. # Project: asdf
  2. # Makefile created by Dev-C++ 4.9.9.2

  3. CPP  = g++.exe -D__DEBUG__
  4. CC   = gcc.exe -D__DEBUG__
  5. WINDRES = windres.exe
  6. RES  =
  7. OBJ  = main.o Socket.o $(RES)
  8. LINKOBJ  = main.o Socket.o $(RES)
  9. LIBS =  -L"lib" ../../../../0Apps/DevCPP/lib/libws2_32.a  -g3
  10. INCS =  -I"include"
  11. CXXINCS =  -I"lib/gcc/mingw32/3.4.2/include"  -I"include/c++/3.4.2/backward"  -I"include/c++/3.4.2/mingw32"  -I"include/c++/3.4.2"  -I"include"
  12. BIN  = "sample program.exe"
  13. CXXFLAGS = $(CXXINCS)   -g3
  14. CFLAGS = $(INCS)   -g3
  15. RM = rm -f

  16. .PHONY: all all-before all-after clean clean-custom

  17. all: all-before "sample program.exe" all-after


  18. clean: clean-custom
  19.         ${RM} $(OBJ) $(BIN)

  20. $(BIN): $(OBJ)
  21.         $(CPP) $(LINKOBJ) -o "sample program.exe" $(LIBS)

  22. main.o: main.cpp
  23.         $(CPP) -c main.cpp -o main.o $(CXXFLAGS)

  24. Socket.o: Socket.cpp
  25.         $(CPP) -c Socket.cpp -o Socket.o $(CXXFLAGS)
复制代码




收藏收藏0

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

2#
发表于 2011-5-30 06:34 PM |只看该作者
當我compile 的時候出現這個信息,請問該怎樣解決

C:\Users\Eric\Desktop\sad\Makefile.win   ["sample ...
狂天使 发表于 2011-5-30 03:09 AM



那是你 compiler 設置上的問題了, 我用 CB 測試了一下樓主的 coding 大致上是沒問題



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-25 10:34 PM , Processed in 0.106164 second(s), 26 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部