• 검색 결과가 없습니다.

Static/Dynamic Library

N/A
N/A
Protected

Academic year: 2021

Share "Static/Dynamic Library"

Copied!
23
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Static Library

&

Shared Library

Wanho Choi

(wanochoi.com)

(2)
(3)

#include <iostream> class MyClass { private: float _x; public: MyClass();

void set( float x ); float get() const; };

int main( int argc, char* argv[] ) {

MyClass a;

a.set( 123.456f );

std::cout << a.get() << std::endl; return 0; }

main.cpp

MyClass::MyClass() { _x = 0.f; }

void MyClass::set( float x ) {

_x = x; }

float MyClass::get() const {

return _x; }

(4)

g++ -o main main.cpp;

./main;

(5)
(6)

#ifndef _MyClass_h_ #define _MyClass_h_ class MyClass { private: float _x; public: MyClass();

void set( float x ); float get() const; };

#endif

#include <iostream> #include “MyClass.h”

int main( int argc, char* argv[] ) {

MyClass a;

a.set( 123.456f );

std::cout << a.get() << std::endl; return 0; }

main.cpp

MyClass::MyClass() { _x = 0.f; }

void MyClass::set( float x ) {

_x = x; }

float MyClass::get() const {

return _x; }

(7)

g++ -o main main.cpp;

./main;

(8)
(9)

#ifndef _MyClass_h_ #define _MyClass_h_ class MyClass { private: float _x; public: MyClass();

void set( float x ); float get() const; };

#endif

#include <iostream>

#include <MyClass.h>

int main( int argc, char* argv[] ) {

MyClass a;

a.set( 123.456f );

std::cout << a.get() << std::endl; return 0; }

main.cpp

MyClass::MyClass() { _x = 0.f; }

void MyClass::set( float x ) {

_x = x; }

float MyClass::get() const {

return _x; }

(10)

g++ -o main main.cpp

-I.

;

./main;

(11)
(12)

#ifndef _MyClass_h_ #define _MyClass_h_ class MyClass { private: float _x; public: MyClass();

void set( float x ); float get() const; };

#endif

#include <iostream> #include <MyClass.h>

int main( int argc, char* argv[] ) {

MyClass a;

a.set( 123.456f );

std::cout << a.get() << std::endl; return 0; }

main.cpp

MyClass.h

#include <MyClass.h> MyClass::MyClass() { _x = 0.f; }

void MyClass::set( float x ) {

_x = x; }

float MyClass::get() const {

return _x; }

(13)

g++ -c MyClass.cpp -I.;

g++ -o main main.cpp MyClass.o -I.;

./main;

123.456

(14)
(15)

#ifndef _MyClass_h_ #define _MyClass_h_ class MyClass { private: float _x; public: MyClass();

void set( float x ); float get() const; }; #endif

MyClass.h

#include <MyClass.h> MyClass::MyClass() { _x = 0.f; }

void MyClass::set( float x ) {

_x = x; }

float MyClass::get() const {

return _x; }

(16)

g++ -O3 -m64 -c MyClass.cpp -o MyClass.o -I.;

ar -r libMyStaticLibrary.a MyClass.o;

(17)

#include <iostream> #include <MyClass.h>

int main( int argc, char* argv[] ) {

MyClass a;

a.set( 123.456f );

std::cout << a.get() << std::endl; return 0;

}

(18)

g++ -o main main.cpp -I. -L. -lMyStaticLibrary;

./main

123.456

(19)
(20)

#ifndef _MyClass_h_ #define _MyClass_h_ class MyClass { private: float _x; public: MyClass();

void set( float x ); float get() const; }; #endif

MyClass.h

#include <MyClass.h> MyClass::MyClass() { _x = 0.f; }

void MyClass::set( float x ) {

_x = x; }

float MyClass::get() const {

return _x; }

(21)

g++ -O3 -m64 -fpic -c MyClass.cpp -o MyClass.o -I.;

g++

-shared

-o

libMySharedLibrary.so

MyClass.o;

(22)

#include <iostream> #include <MyClass.h>

int main( int argc, char* argv[] ) {

MyClass a;

a.set( 123.456f );

std::cout << a.get() << std::endl; return 0;

}

(23)

g++ -o main main.cpp -I. -L.

-lMySharedLibrary

;

export LD_LIBRARY_PATH=../07_shared_library;

./main;

참조

관련 문서

[r]

(Attached to a noun) This is used to indicate the topics, to compare two information or to emphasize the preceding noun in a sentence.. (Attached to a noun) This is used

짝과 같이 말하기 연습을 하도록 하고 교사는 교실을 돌아다니면서 말하기 활동이 제대로 이루어지고 있 는지 확인하고 도움을 준다.. 평소에 누구하고 무엇을 하는지

(Attached to a verb) This is used to show that the succeeding action takes place right after the preceding action.. (Attached to a verb) This is used to indicate a

(Attached to a verb or an adjective) This is used to indicate a succeeding action or situation. This is used

(Attached to a verb or an adjective) This is used to reflect on a past situation. (Attached to an adjective) This is used to show another

발표를 듣고 느낀 점이나 서로의 생각을 이야기해 보 게 하면서

(Attached to a noun) This is used to indicate an object has the characteristics and qualities of both a preceding and succeeding