2014-09-08 2 views
2

나는 this 튜토리얼을 따르려고했는데, 지금까지 이걸 가지고있다.SFML 2.1 네트워킹

#include <SFML/Network.hpp> 
#include <SFML/System.hpp> 
#include <iostream> 
using namespace std; 
int main(){ 
    sf::IpAddress ip=sf::IpAddress::getLocalAddress(); 
    sf::TcpSocket socket; 
    char connectiontype,mode; 
    char buffer[2000]; 
    size_t received; 
    cout<<"s for server, c for client"<<endl; 
    cin>>connectiontype; 
    string text="connected to "; 
    if(connectiontype=='s'){ 
     sf::TcpListener listener; 
     listener.listen(3000); 
     listener.accept(socket); 
     text+="server"; 
     mode='s'; 
    } 
    else if(connectiontype=='c'){ 
     socket.connect(ip,3000); 
     text+="client"; 
     mode='r'; 
    } 
    socket.send(text.c_str(),text.length()+1); 
    socket.receive(buffer,sizeof(buffer),received); 
    cout<<buffer<<endl; 

    bool done=false; 

    while(!done){ 
     if(mode=='s'){ 
      getline(cin,text); 
      socket.send(text.c_str(),text.length()+1); 
      mode='r'; 
     } 
     else if(mode=='r'){ 
      socket.receive(buffer,sizeof(buffer),received); 
      if(received>0){ 
       cout<<"received: "<<buffer<<endl; 
       mode='s'; 
      } 
     } 
    } 
    return 0; 
} 

나는 그것을 컴파일하고, 이러한 오류를 가지고 : enter image description here

가 나는 또한 내 프로젝트 폴더에 sfml-network-2.dllsfml-network-d-2.dll를 추가하려했지만 작동하지 않았다.

나는 모든 것을 올바르게 설정했다고 확신합니다.
이 내 설정이다 : enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here 당신이 괜찮다면 내가, 내 이름을 포함 enter image description here enter image description here

. 감사!

업데이트 :

내가 SFML을 다시 설치 한, 나는 내 코드 내 오류를 업데이트했습니다.

+0

Windows에서의 SFML/C :: B 설정에서 라이브러리 경로는 지정하지 않지만 이름은 예 : sfml-window 만 있고 전체 경로는 아닙니다. 'ld'이 라이브러리를 찾지 못하는 것 같습니다. :/ – pentix

+0

좋습니다, 고마워요. – user3882772

답변

1

나는 내 문제를 해결했습니다!
각 라이브러리는 이름이 아닌 위치가 변경되었습니다.
예 : sfml-network

+1

이것은 기본적으로 내 코멘트에 포함됩니다;) 재미있게 보내십시오! – pentix

+1

코멘트 주셔서 감사합니다! – user3882772

0

모두 올바르게 설정했다면 컴파일러 포함 경로에 SFML 경로를 추가하고 링커 경로에 SFML DLL을 추가 했습니까?

Code :: Blocks를 사용할 때 여기에 설명 된대로 정확하게 "온라인 게임"프로젝트를 설정 했습니까?

http://www.sfml-dev.org/tutorials/2.1/start-cb.php

업데이트 : http://www.sfml-dev.org/tutorials/2.1/images/start-cb-link-libs.png

당신이 라이브러리 목록에서 sfml-network있어, 당신에게 확실 :

이 그림에서보세요? 이것은 문제 일 수 있습니다.

dll을 프로젝트 폴더에 추가하는 것은 도움이되지 않습니다. 컴파일러/링커 오류이고 런타임 라이브러리 오류가 아니기 때문입니다.

+0

라이브러리 목록에 sfml-network가 있습니다. SFML/System.hpp를 포함하여 시도했지만 도움이되지 않았습니다. – user3882772

+0

프로젝트 구성을 보여주는 사진을 게시 할 수 있습니까? (위와 같은 대화 + 검색 디렉토리)? – pentix

+1

OK, 나는하겠다. (이제 사진을 올리려면 10 명의 담당자가있다.) – user3882772

0

sfml-system에도 링크해야합니다.

보조 노트로 소켓 here에 대한 공식적인 예를 찾을 수 있습니다.

+0

sfml-system에 링크되어있다. – user3882772