├── images
├── image1.png
└── image2.png
├── xcode
├── BasicNeuralNet.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── kretash.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── net.xcodeproj
│ ├── xcuserdata
│ └── kretash.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
│ └── project.pbxproj
├── .gitattributes
├── vs2015
├── net.vcxproj.user
├── BasicNeuralNet.sln
├── net.vcxproj.filters
└── net.vcxproj
├── src
├── layer.cc
├── link.cc
├── main.cc
├── network.cc
└── node.cc
├── .gitignore
├── README.md
└── include
└── network.hh
/images/image1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kretash/BasicNeuralNet/HEAD/images/image1.png
--------------------------------------------------------------------------------
/images/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kretash/BasicNeuralNet/HEAD/images/image2.png
--------------------------------------------------------------------------------
/xcode/BasicNeuralNet.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/xcode/BasicNeuralNet.xcworkspace/xcuserdata/kretash.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kretash/BasicNeuralNet/HEAD/xcode/BasicNeuralNet.xcworkspace/xcuserdata/kretash.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/xcode/net.xcodeproj/xcuserdata/kretash.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | net.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/vs2015/net.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WindowsLocalDebugger
5 |
6 |
7 |
8 | WindowsLocalDebugger
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/layer.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "network.hh"
4 |
5 | Layer::Layer( int32_t nodes, std::string name ) {
6 | this->m_name = name;
7 | for( int32_t i = 0; i < nodes; ++i ) {
8 | std::shared_ptr n = std::make_shared( name + " Node " + std::to_string( i ) );
9 | m_nodes.push_back( n );
10 | }
11 | }
12 |
13 | void Layer::project( std::shared_ptr other_layer ) {
14 | for( auto i_node : m_nodes ) {
15 | for( auto o_node : other_layer->m_nodes ) {
16 |
17 | std::shared_ptr link = std::make_shared( i_node, o_node );
18 | i_node->add_f_link( link );
19 | o_node->add_b_link( link );
20 |
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
49 | bin
--------------------------------------------------------------------------------
/vs2015/BasicNeuralNet.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "net", "net.vcxproj", "{4C94880B-B89D-887C-4119-9F7CAD21947C}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | debug|x64 = debug|x64
9 | release|x64 = release|x64
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {4C94880B-B89D-887C-4119-9F7CAD21947C}.debug|x64.ActiveCfg = debug|x64
13 | {4C94880B-B89D-887C-4119-9F7CAD21947C}.debug|x64.Build.0 = debug|x64
14 | {4C94880B-B89D-887C-4119-9F7CAD21947C}.release|x64.ActiveCfg = release|x64
15 | {4C94880B-B89D-887C-4119-9F7CAD21947C}.release|x64.Build.0 = release|x64
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | GlobalSection(NestedProjects) = preSolution
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/src/link.cc:
--------------------------------------------------------------------------------
1 | #include "network.hh"
2 |
3 | Link::Link( std::shared_ptr from, std::shared_ptr to, std::string name ) {
4 | this->m_name = name;
5 | m_link_from = from;
6 | m_link_to = to;
7 | m_weight = random( -1.0, 1.0 );
8 | }
9 |
10 | void Link::_push( double value ) {
11 | m_link_to->_push( value * m_weight );
12 | }
13 |
14 | void Link::_compute_error( double delta, double learning_rate ) {
15 |
16 | double this_delta = delta * m_weight;
17 |
18 | if (m_link_from->m_b_links.size() != 0)
19 | m_link_from->_compute_error( this_delta, learning_rate );
20 | }
21 |
22 | void Link::_backpropagate( double learning_rate ) {
23 |
24 | const double lamda = 0.0;
25 |
26 | m_weight +=
27 | learning_rate
28 | * ( ( m_link_to->m_delta * m_link_from->m_value ) + ( lamda * m_link_from->m_value ) )
29 | + ( s_alpha * m_link_to->m_delta_weight );
30 |
31 | m_link_to->m_delta_weight = learning_rate * m_link_to->m_delta * m_link_from->m_value;
32 |
33 | // Stop at input nodes
34 | if( m_link_from->m_b_links.size() != 0 )
35 | m_link_from->_backpropagate( learning_rate);
36 |
37 | }
--------------------------------------------------------------------------------
/vs2015/net.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {2DAB880B-99B4-887C-2230-9F7C8E38947C}
6 |
7 |
8 | {89AF369E-F58E-B539-FEA6-40106A051C9B}
9 |
10 |
11 |
12 |
13 | include
14 |
15 |
16 |
17 |
18 | src
19 |
20 |
21 | src
22 |
23 |
24 | src
25 |
26 |
27 | src
28 |
29 |
30 | src
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "network.hh"
6 |
7 | int main( int argc, char** argv ) {
8 |
9 | srand( ( uint32_t ) time( nullptr ) );
10 |
11 | // create all the resources
12 | std::shared_ptr input_layer = std::make_shared( 2, "Input Layer" );
13 | std::shared_ptr hidden_layer = std::make_shared( 3, "Hidden Layer" );
14 | std::shared_ptr output_layer = std::make_shared( 1 , "Output Layer" );
15 |
16 | input_layer->project( hidden_layer );
17 | hidden_layer->project( output_layer );
18 |
19 | std::shared_ptr network = std::make_shared( input_layer, output_layer );
20 |
21 | const double learning_rate = 0.5;
22 | // train the network - learn XOR
23 | for( uint32_t i = 0; i < 50000; ++i ) {
24 |
25 | network->activate( { 0,0 } );
26 | network->propagate( learning_rate, { 0 } );
27 |
28 | network->activate( { 0,1 } );
29 | network->propagate( learning_rate, { 1 } );
30 |
31 | network->activate( { 1,0 } );
32 | network->propagate( learning_rate, { 1 } );
33 |
34 | network->activate( { 1,1 } );
35 | network->propagate( learning_rate, { 0 } );
36 | }
37 |
38 | std::cout << " 0 XOR 0 -> " << network->activate( { 0,0 } )[0] << "\n";
39 | std::cout << " 0 XOR 1 -> " << network->activate( { 0,1 } )[0] << "\n";
40 | std::cout << " 1 XOR 0 -> " << network->activate( { 1,0 } )[0] << "\n";
41 | std::cout << " 1 XOR 1 -> " << network->activate( { 1,1 } )[0] << "\n";
42 |
43 | return 0;
44 | }
45 |
--------------------------------------------------------------------------------
/src/network.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "network.hh"
6 |
7 | #define FAKE_RANDOM 0
8 |
9 | double random( double min, double max ) {
10 | #if FAKE_RANDOM
11 | return min + (max - min)*0.75;
12 | #else
13 | static std::random_device rd;
14 | static std::mt19937 gen(rd());
15 | std::uniform_real_distribution<> dis(min, max);
16 | return dis(gen);
17 | #endif
18 | }
19 |
20 | std::vector Network::activate( std::vector inputs ) {
21 |
22 | auto inodes = m_input_layer->m_nodes;
23 |
24 | assert( inputs.size() == inodes.size() &&
25 | "INPUT MUST BE THE SIZE OF THE NODES IN THE INPUT LAYER" );
26 |
27 | for( size_t i = 0; i < inodes.size(); ++i ) {
28 | inodes[i]->_input( inputs[i] );
29 | }
30 |
31 | std::vector outputs;
32 | for( auto o : m_output_layer->m_nodes ) {
33 | outputs.push_back( o->m_value );
34 | }
35 | return outputs;
36 | }
37 |
38 | void Network::propagate( double learning_rate, std::vector target ) {
39 |
40 | auto onodes = m_output_layer->m_nodes;
41 |
42 | assert( target.size() == onodes.size() &&
43 | "RESULTS MUST BE THE SIZE OF THE NODES IN THE OUTPUT LAYER" );
44 |
45 | for( size_t i = 0; i < onodes.size(); ++i ) {
46 |
47 | auto on = onodes[i];
48 | double this_error = target[i] - on->m_value;
49 | on->_start_compute_error( this_error, learning_rate );
50 |
51 | }
52 |
53 | for( size_t i = 0; i < onodes.size(); ++i ) {
54 | auto on = onodes[i];
55 | on->_start_backpropagate( learning_rate );
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/node.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include "network.hh"
3 |
4 | void Node::add_f_link( std::shared_ptr link ) {
5 | link->m_name += "(" + this->m_name + " -> link forward)";
6 | m_f_links.push_back( link );
7 | }
8 |
9 | void Node::add_b_link( std::shared_ptr link ) {
10 | link->m_name += "(" + this->m_name + " -> <- link back)";
11 | m_b_links.push_back( link );
12 | }
13 |
14 | void Node::_input( double value ){
15 |
16 | m_value = value;
17 |
18 | for( auto link : m_f_links ) {
19 | link->_push( m_value );
20 | }
21 |
22 | m_synapse_sum = 0;
23 | m_forward_load = 0;
24 | }
25 |
26 | void Node::_push( double value ) {
27 | m_synapse_sum += value;
28 | ++m_forward_load;
29 | if( m_forward_load == m_b_links.size() ) {
30 | _fire();
31 | }
32 | }
33 |
34 | // transfer function
35 | double Node::_sigmoid( double num ) {
36 | return ( 1.0 / ( 1.0 + exp( -num ) ) );
37 | }
38 |
39 | void Node::_fire() {
40 |
41 | m_value = _sigmoid( m_synapse_sum + m_bias );
42 |
43 | m_synapse_sum = 0;
44 | m_forward_load = 0;
45 |
46 | if( m_end_node ) return;
47 |
48 | for( auto link : m_f_links ) {
49 | link->_push( m_value );
50 | }
51 | }
52 |
53 | void Node::_start_compute_error( double delta, double learning_rate ) {
54 |
55 | m_delta = ( 1.0 - m_value ) * m_value * delta;
56 |
57 | m_error_sum = 0.0;
58 | m_backward_load = 0;
59 |
60 | for( auto blinks : m_b_links ) {
61 | blinks->_compute_error( m_delta, learning_rate );
62 | }
63 | }
64 |
65 | void Node::_compute_error( double delta, double learning_rate ) {
66 |
67 | m_error_sum += delta;
68 |
69 | ++m_backward_load;
70 | if( m_backward_load == m_f_links.size() ) {
71 |
72 | m_delta = ( 1.0 - m_value ) * m_value * m_error_sum;
73 |
74 | m_error_sum = 0.0;
75 | m_backward_load = 0;
76 |
77 | for( auto blinks : m_b_links ) {
78 | blinks->_compute_error( m_delta, learning_rate );
79 | }
80 | }
81 | }
82 |
83 | void Node::_start_backpropagate( double learning_rate ) {
84 |
85 | m_bias += learning_rate * m_delta;
86 |
87 | m_backward_load = 0;
88 |
89 | for( auto blinks : m_b_links ) {
90 | blinks->_backpropagate( learning_rate );
91 | }
92 | }
93 |
94 | void Node::_backpropagate( double learning_rate ) {
95 |
96 | ++m_backward_load;
97 | if( m_backward_load == m_f_links.size() ) {
98 |
99 | m_bias += learning_rate * m_delta;
100 |
101 | m_backward_load = 0;
102 |
103 | for( auto blinks : m_b_links ) {
104 | blinks->_backpropagate( learning_rate );
105 | }
106 |
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Basic Neural Net
2 |
3 | The most basic neural net you can build. Completly from scratch in C++.
4 |
5 | This network currently trains and produces results for an XOR.
6 |
7 | ---
8 |
9 | ## Building the network
10 |
11 | The first thing we do is create the different layers. We specify how many nodes each layer has.
12 |
13 | ```cpp
14 | std::shared_ptr input_layer = std::make_shared( 2, "Input Layer" );
15 | std::shared_ptr hidden_layer = std::make_shared( 3, "Hidden Layer" );
16 | std::shared_ptr output_layer = std::make_shared( 1 , "Output Layer" );
17 | ```
18 |
19 | ![image1]
20 |
21 | The next step is to create the links between the layers and create a network. The function **project** will connect all the nodes in a layer to the layer passed as an argument.
22 |
23 | ```cpp
24 | input_layer->project( hidden_layer );
25 | hidden_layer->project( output_layer );
26 | ```
27 |
28 | This is how our layers look now.
29 |
30 | ![image2]
31 |
32 | Finally, to create the network we need pass the input and output layers.
33 |
34 | ```cpp
35 | std::shared_ptr network = std::make_shared( input_layer, output_layer );
36 | ```
37 |
38 | ## Using the Network
39 |
40 | To use the network we call the function **activate**. This function will take an std::vector as a parameter that should match in size with the number of nodes in the input layer. The return vector will be the same size as the number of output nodes.
41 |
42 | ```cpp
43 | std::vector output = network->activate( { 0,0 } );
44 | ```
45 |
46 | The output values we will get the first times we use the network will be random. In order to train the network we can call **propagate** after an activate to trains the network. We want to pass in a learning rate and the target results. The learning rate is just a constant defined to 0.5 and the target results must be an std::vector that matches in size with the amount of output nodes. The learning rate can be tweaked to achieve better results.
47 |
48 | ```cpp
49 | network->propagate( learning_rate, { 0 } );
50 | ```
51 |
52 | Once this is done a multitude of times with all posible values the results from the activate will start to match the target results.
53 |
54 | ---
55 |
56 | ## Building
57 |
58 | There is a Visual Studio solution file and xcode project that can be use to build. There is only a small number of files, so building from the command line would be easy too.
59 |
60 | ### License
61 |
62 | MIT License
63 |
64 | [image1]: https://github.com/kretash/BasicNeuralNet/raw/master/images/image1.png "Layers"
65 | [image2]: https://github.com/kretash/BasicNeuralNet/raw/master/images/image2.png "Final Network"
66 |
--------------------------------------------------------------------------------
/include/network.hh:
--------------------------------------------------------------------------------
1 | /*
2 | Defines Network, Layer, Node and Link
3 | Author: Carlos Martinez Romero (kretash)
4 | License: MIT License
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | double random( double min, double max );
12 |
13 | class Node;
14 |
15 | static int32_t s_component_id_count = 0;
16 | static const double s_alpha = 0.1; // Momentum
17 |
18 | class Component {
19 | protected:
20 | Component() {
21 | m_component_id = ++s_component_id_count;
22 | }
23 | public:
24 | Component(std::string name) {
25 | m_component_id = ++s_component_id_count;
26 | m_name = name;
27 | }
28 | ~Component() {
29 |
30 | }
31 | std::string m_name = "Nameless X";
32 | int32_t m_component_id = 0;
33 | };
34 |
35 | class Link : public Component {
36 | protected:
37 | Link() {}
38 | public:
39 | Link( std::shared_ptr from, std::shared_ptr to, std::string name = "Link X" );
40 | ~Link() {}
41 |
42 | private:
43 | friend class Node;
44 |
45 | void _push( double value );
46 |
47 | void _compute_error( double delta, double learning_rate );
48 | void _backpropagate( double learning_rate );
49 |
50 | double m_weight = 0.0;
51 |
52 | std::shared_ptr m_link_to;
53 | std::shared_ptr m_link_from;
54 | };
55 |
56 | class Node : public Component {
57 | protected:
58 | Node(){
59 | // Not used
60 | m_bias = random( 0.0, 1.0 );
61 | }
62 | public:
63 | Node(std::string name = "Layer X" ) {
64 | this->m_name = name;
65 | m_bias = random( 0.0, 1.0 );
66 | };
67 | ~Node() {};
68 |
69 | void add_f_link( std::shared_ptr link );
70 | void add_b_link( std::shared_ptr link );
71 |
72 | private:
73 | friend class Network;
74 | friend class Link;
75 |
76 | // Used by the first node to input values into the net.
77 | void _input( double value );
78 |
79 | double _sigmoid( double num );
80 | // pushes a value to the node. When all links have been pushed
81 | // the node will fire the values forward.
82 | // at the beginning of the network there will be no way to start as there are no back links.
83 | // once all back links have pushed the nodes will fire. If this is the first node it needs
84 | // force start to true as there will be no back nodes.
85 | void _push( double value );
86 | void _fire();
87 |
88 | // computes the error. similar to push but backwards. Start function.
89 | void _start_compute_error( double delta, double learning_rate );
90 | // computes the error. similar to push but backwards.
91 | void _compute_error( double delta, double learning_rate);
92 |
93 | // First backpropagate
94 | void _start_backpropagate( double learning_rate );
95 | void _backpropagate( double learning_rate );
96 |
97 | bool m_end_node = false;
98 |
99 | // The last value fired forward.
100 | double m_value = 0.0;
101 | // the sum of all the values of fired to this node.
102 | double m_synapse_sum = 0.0;
103 |
104 | double m_error_sum = 0.0;
105 | double m_delta = 0.0;
106 | double m_delta_weight = 0.0;
107 | double m_bias = 0.0;
108 |
109 | // When the load is equal to the number of back links the node will fire.
110 | int32_t m_forward_load = 0;
111 | // When the load is equal to the number of forward the node will fire back.
112 | // Calculating the error made from the previous iteration.
113 | int32_t m_backward_load = 0;
114 |
115 | std::vector> m_f_links;
116 | std::vector> m_b_links;
117 |
118 | };
119 |
120 | class Layer : public Component {
121 | protected:
122 | Layer() {}
123 |
124 | public:
125 | Layer( int32_t nodes, std::string name = "Layer X" );
126 | ~Layer() {}
127 |
128 | void project( std::shared_ptr other_layer );
129 |
130 | private:
131 | friend class Network;
132 |
133 | std::vector> m_nodes;
134 | };
135 |
136 | class Network : public Component {
137 | protected:
138 | Network() {}
139 | public:
140 |
141 | Network( std::shared_ptr input, std::shared_ptr output ) :
142 | m_input_layer( input ), m_output_layer( output ) {
143 | for( auto n : m_output_layer->m_nodes ) {
144 | n->m_end_node = true;
145 | }
146 | }
147 |
148 | ~Network() {}
149 |
150 | std::vector activate( std::vector inputs );
151 | void propagate( double learning_rate, std::vector results );
152 |
153 | private:
154 | std::shared_ptr m_input_layer;
155 | std::shared_ptr m_output_layer;
156 |
157 | };
158 |
--------------------------------------------------------------------------------
/vs2015/net.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | debug
6 | x64
7 |
8 |
9 | release
10 | x64
11 |
12 |
13 |
14 | {4C94880B-B89D-887C-4119-9F7CAD21947C}
15 | net
16 | 8.1
17 | Win32Proj
18 |
19 |
20 |
21 | Application
22 | true
23 | v140
24 |
25 |
26 | Application
27 | false
28 | v140
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | ..\bin\
42 | obj\x64\debug\
43 | net-d
44 | .exe
45 | true
46 |
47 |
48 | ..\bin\
49 | obj\x64\release\
50 | net
51 | .exe
52 | false
53 |
54 |
55 |
56 | %(AdditionalOptions)
57 | Disabled
58 | ..\include;%(AdditionalIncludeDirectories)
59 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;DEBUG;%(PreprocessorDefinitions)
60 | false
61 | EnableFastChecks
62 | MultiThreadedDebugDLL
63 | true
64 | true
65 |
66 | Level3
67 | EditAndContinue
68 | $(OutDir)net-d.pdb
69 |
70 |
71 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;DEBUG;%(PreprocessorDefinitions)
72 | ..\include;%(AdditionalIncludeDirectories)
73 |
74 |
75 | Console
76 | true
77 | $(OutDir)net-d.exe
78 | mainCRTStartup
79 | MachineX64
80 |
81 |
82 |
83 |
84 | %(AdditionalOptions)
85 | Full
86 | ..\include;%(AdditionalIncludeDirectories)
87 | WIN32;NDEBUG;%(PreprocessorDefinitions)
88 | false
89 | true
90 | MultiThreadedDLL
91 | true
92 | true
93 |
94 | Level3
95 |
96 |
97 |
98 | WIN32;NDEBUG;%(PreprocessorDefinitions)
99 | ..\include;%(AdditionalIncludeDirectories)
100 |
101 |
102 | Console
103 | false
104 | true
105 | true
106 | $(OutDir)net.exe
107 | mainCRTStartup
108 | MachineX64
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | $(IntDir)src\
117 |
118 |
119 | $(IntDir)src\
120 |
121 |
122 | $(IntDir)src\
123 |
124 |
125 | $(IntDir)src\
126 |
127 |
128 | $(IntDir)src\
129 |
130 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/xcode/net.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 093548BD21E917CE32BA7E73 /* network.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1E37683751E666181FDD655F /* network.cc */; };
11 | 09CB1C5B28B7545A0677586C /* link.cc in Sources */ = {isa = PBXBuildFile; fileRef = 28DF3C8A0E9969FD5C8A077B /* link.cc */; };
12 | 206D2FAC65C20DC3239D1B98 /* node.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1F493C861ACF480110E02147 /* node.cc */; };
13 | 2AA710BB47E137A61379231C /* layer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 319658A847D2562329565901 /* layer.cc */; };
14 | 7D62676C17D445353D8F412A /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1ECB447B6D5573F135D53F2C /* main.cc */; };
15 | /* End PBXBuildFile section */
16 |
17 | /* Begin PBXFileReference section */
18 | 0A14644F49DC52CE2FF716B6 /* net-d */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "net-d"; sourceTree = BUILT_PRODUCTS_DIR; };
19 | 1E37683751E666181FDD655F /* network.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = network.cc; path = ../src/network.cc; sourceTree = ""; };
20 | 1ECB447B6D5573F135D53F2C /* main.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = main.cc; path = ../src/main.cc; sourceTree = ""; };
21 | 1F493C861ACF480110E02147 /* node.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = node.cc; path = ../src/node.cc; sourceTree = ""; };
22 | 28DF3C8A0E9969FD5C8A077B /* link.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = link.cc; path = ../src/link.cc; sourceTree = ""; };
23 | 319658A847D2562329565901 /* layer.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = layer.cc; path = ../src/layer.cc; sourceTree = ""; };
24 | 3FD1213B4A8E6A1B2FB44A71 /* network.hh */ = {isa = PBXFileReference; lastKnownFileType = text; name = network.hh; path = ../include/network.hh; sourceTree = ""; };
25 | /* End PBXFileReference section */
26 |
27 | /* Begin PBXFrameworksBuildPhase section */
28 | 39A9134041331F6C210464D0 /* Frameworks */ = {
29 | isa = PBXFrameworksBuildPhase;
30 | buildActionMask = 2147483647;
31 | files = (
32 | );
33 | runOnlyForDeploymentPostprocessing = 0;
34 | };
35 | /* End PBXFrameworksBuildPhase section */
36 |
37 | /* Begin PBXGroup section */
38 | 29106B7C411D200078E21FCE /* include */ = {
39 | isa = PBXGroup;
40 | children = (
41 | 3FD1213B4A8E6A1B2FB44A71 /* network.hh */,
42 | );
43 | name = include;
44 | sourceTree = "";
45 | };
46 | 3E0314E95525715A51D60971 /* src */ = {
47 | isa = PBXGroup;
48 | children = (
49 | 319658A847D2562329565901 /* layer.cc */,
50 | 28DF3C8A0E9969FD5C8A077B /* link.cc */,
51 | 1ECB447B6D5573F135D53F2C /* main.cc */,
52 | 1E37683751E666181FDD655F /* network.cc */,
53 | 1F493C861ACF480110E02147 /* node.cc */,
54 | );
55 | name = src;
56 | sourceTree = "";
57 | };
58 | 4CEF2100030464C366354094 /* Products */ = {
59 | isa = PBXGroup;
60 | children = (
61 | 0A14644F49DC52CE2FF716B6 /* net-d */,
62 | );
63 | name = Products;
64 | sourceTree = "";
65 | };
66 | 67646EDF0CFE02BD5B3B7139 /* net */ = {
67 | isa = PBXGroup;
68 | children = (
69 | 29106B7C411D200078E21FCE /* include */,
70 | 3E0314E95525715A51D60971 /* src */,
71 | 4CEF2100030464C366354094 /* Products */,
72 | );
73 | name = net;
74 | sourceTree = "";
75 | };
76 | /* End PBXGroup section */
77 |
78 | /* Begin PBXNativeTarget section */
79 | 5DAF387A1B586C5C643A2653 /* net */ = {
80 | isa = PBXNativeTarget;
81 | buildConfigurationList = 25EE046C28CB77D46A8448A8 /* Build configuration list for PBXNativeTarget "net" */;
82 | buildPhases = (
83 | 5D3473B911657F1D0B884420 /* Resources */,
84 | 7D912AD100A6186172D31186 /* Sources */,
85 | 39A9134041331F6C210464D0 /* Frameworks */,
86 | );
87 | buildRules = (
88 | );
89 | dependencies = (
90 | );
91 | name = net;
92 | productInstallPath = "$(HOME)/bin";
93 | productName = net;
94 | productReference = 0A14644F49DC52CE2FF716B6 /* net-d */;
95 | productType = "com.apple.product-type.tool";
96 | };
97 | /* End PBXNativeTarget section */
98 |
99 | /* Begin PBXProject section */
100 | __RootObject_ /* Project object */ = {
101 | isa = PBXProject;
102 | attributes = {
103 | };
104 | buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "net" */;
105 | compatibilityVersion = "Xcode 3.2";
106 | developmentRegion = en;
107 | hasScannedForEncodings = 1;
108 | knownRegions = (
109 | en,
110 | );
111 | mainGroup = 67646EDF0CFE02BD5B3B7139 /* net */;
112 | projectDirPath = "";
113 | projectRoot = "";
114 | targets = (
115 | 5DAF387A1B586C5C643A2653 /* net */,
116 | );
117 | };
118 | /* End PBXProject section */
119 |
120 | /* Begin PBXResourcesBuildPhase section */
121 | 5D3473B911657F1D0B884420 /* Resources */ = {
122 | isa = PBXResourcesBuildPhase;
123 | buildActionMask = 2147483647;
124 | files = (
125 | );
126 | runOnlyForDeploymentPostprocessing = 0;
127 | };
128 | /* End PBXResourcesBuildPhase section */
129 |
130 | /* Begin PBXSourcesBuildPhase section */
131 | 7D912AD100A6186172D31186 /* Sources */ = {
132 | isa = PBXSourcesBuildPhase;
133 | buildActionMask = 2147483647;
134 | files = (
135 | 2AA710BB47E137A61379231C /* layer.cc in Sources */,
136 | 09CB1C5B28B7545A0677586C /* link.cc in Sources */,
137 | 7D62676C17D445353D8F412A /* main.cc in Sources */,
138 | 093548BD21E917CE32BA7E73 /* network.cc in Sources */,
139 | 206D2FAC65C20DC3239D1B98 /* node.cc in Sources */,
140 | );
141 | runOnlyForDeploymentPostprocessing = 0;
142 | };
143 | /* End PBXSourcesBuildPhase section */
144 |
145 | /* Begin XCBuildConfiguration section */
146 | 06D13E61248C50AE112F5484 /* release */ = {
147 | isa = XCBuildConfiguration;
148 | buildSettings = {
149 | ARCHS = x86_64;
150 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
151 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
152 | GCC_C_LANGUAGE_STANDARD = gnu99;
153 | GCC_OPTIMIZATION_LEVEL = s;
154 | GCC_PREPROCESSOR_DEFINITIONS = (
155 | WIN32,
156 | NDEBUG,
157 | );
158 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
159 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
160 | GCC_WARN_UNUSED_VARIABLE = YES;
161 | HEADER_SEARCH_PATHS = ../include;
162 | OBJROOT = obj/x64/release;
163 | ONLY_ACTIVE_ARCH = NO;
164 | SDKROOT = macosx;
165 | SYMROOT = ../bin;
166 | };
167 | name = release;
168 | };
169 | 10404FE376EF0D655EB01FD1 /* debug */ = {
170 | isa = XCBuildConfiguration;
171 | buildSettings = {
172 | ALWAYS_SEARCH_USER_PATHS = NO;
173 | CLANG_CXX_LANGUAGE_STANDARD = "c++17";
174 | CLANG_CXX_LIBRARY = "libc++";
175 | CONFIGURATION_BUILD_DIR = ../bin;
176 | GCC_DYNAMIC_NO_PIC = NO;
177 | GCC_MODEL_TUNING = G5;
178 | GCC_PREPROCESSOR_DEFINITIONS = (
179 | _CRT_SECURE_NO_WARNINGS,
180 | _DEBUG,
181 | DEBUG,
182 | );
183 | INSTALL_PATH = /usr/local/bin;
184 | MACOSX_DEPLOYMENT_TARGET = 10.10;
185 | PRODUCT_NAME = "net-d";
186 | };
187 | name = debug;
188 | };
189 | 28592AC02A4A0E787FE253E8 /* debug */ = {
190 | isa = XCBuildConfiguration;
191 | buildSettings = {
192 | ARCHS = x86_64;
193 | CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
194 | CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
195 | COPY_PHASE_STRIP = NO;
196 | GCC_C_LANGUAGE_STANDARD = gnu99;
197 | GCC_OPTIMIZATION_LEVEL = 0;
198 | GCC_PREPROCESSOR_DEFINITIONS = (
199 | _CRT_SECURE_NO_WARNINGS,
200 | WIN32,
201 | _DEBUG,
202 | DEBUG,
203 | );
204 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
205 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
206 | GCC_WARN_UNUSED_VARIABLE = YES;
207 | HEADER_SEARCH_PATHS = ../include;
208 | OBJROOT = obj/x64/debug;
209 | ONLY_ACTIVE_ARCH = YES;
210 | SDKROOT = macosx;
211 | SYMROOT = ../bin;
212 | };
213 | name = debug;
214 | };
215 | 65340AB333563CEC344C403C /* release */ = {
216 | isa = XCBuildConfiguration;
217 | buildSettings = {
218 | ALWAYS_SEARCH_USER_PATHS = NO;
219 | CLANG_CXX_LANGUAGE_STANDARD = "c++17";
220 | CLANG_CXX_LIBRARY = "libc++";
221 | CONFIGURATION_BUILD_DIR = ../bin;
222 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
223 | GCC_DYNAMIC_NO_PIC = NO;
224 | GCC_MODEL_TUNING = G5;
225 | GCC_PREPROCESSOR_DEFINITIONS = NDEBUG;
226 | INSTALL_PATH = /usr/local/bin;
227 | MACOSX_DEPLOYMENT_TARGET = 10.10;
228 | PRODUCT_NAME = net;
229 | };
230 | name = release;
231 | };
232 | /* End XCBuildConfiguration section */
233 |
234 | /* Begin XCConfigurationList section */
235 | 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "net" */ = {
236 | isa = XCConfigurationList;
237 | buildConfigurations = (
238 | 28592AC02A4A0E787FE253E8 /* debug */,
239 | 06D13E61248C50AE112F5484 /* release */,
240 | );
241 | defaultConfigurationIsVisible = 0;
242 | defaultConfigurationName = debug;
243 | };
244 | 25EE046C28CB77D46A8448A8 /* Build configuration list for PBXNativeTarget "net" */ = {
245 | isa = XCConfigurationList;
246 | buildConfigurations = (
247 | 10404FE376EF0D655EB01FD1 /* debug */,
248 | 65340AB333563CEC344C403C /* release */,
249 | );
250 | defaultConfigurationIsVisible = 0;
251 | defaultConfigurationName = debug;
252 | };
253 | /* End XCConfigurationList section */
254 | };
255 | rootObject = __RootObject_ /* Project object */;
256 | }
257 |
--------------------------------------------------------------------------------