Statistics
| Branch: | Revision:

root / latex / note_w05.tex @ d1ed66aa

History | View | Annotate | Download (8.37 KB)

1
%!TEX root = note.tex
2

    
3
%%%%%%%%%%%%%%%%%%
4
% WEEK 5
5
%%%%%%%%%%%%%%%%%%
6
\section{Week 5}
7
    \subsection{Install additional libraries for python}
8
        \begin{lstlisting}
9
$ make package/python-light/compile V=s
10
make[1]: Entering directory `/home/quynh/Thesis/cc-openwrt'
11
make[1]: *** No rule to make target `package/python-light/compile'.  Stop.
12
make[1]: Leaving directory `/home/quynh/Thesis/cc-openwrt'
13
make: *** [package/python-light/compile] Error 2
14

    
15
$ make package/python-light/install -p packages
16
no /build_dir/target/Python2.7 folder
17

    
18
$ make package/python -p packages
19
The same result as the command above
20
        \end{lstlisting}
21

    
22
        \textbf{ERROR:root:code for hash sha256 was not found.}
23
            Try to add \texttt{libopenssl} ==> It's not working
24

    
25
            Add both \texttt{+libopenssl +openssl-util} ==> Still get the same error
26

    
27
            Add \texttt{+python-openssl}. Since I saw that in \texttt{python-package-openssl.mk} there is a line:
28

    
29
            \begin{lstlisting}
30
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_hashlib.so
31
            \end{lstlisting}
32

    
33
            \texttt{python-openssl} solves the problem
34

    
35
        \textbf{How to check whether openssl is installed}
36

    
37
        \textbf{What to do when adding new dependencies in Makefile}
38

    
39
            Copy the new Makefile
40
            Run make defconfig
41
            The new dependencies will be added in the new configuration. You can check whether the new dependency was added by:
42

    
43
            \begin{lstlisting}
44
./scripts/diffconfig.sh > config.diff
45
cat config.diff
46
            \end{lstlisting}
47

    
48
            NOTE: when removing dependencies, running make defconfig doesn't automatically remove those libraries out of the configuration. So check again whether you need those library, and remove them by hand if needed.
49

    
50
        \textbf{What is the differences between openssl-util and libopenssl}
51

    
52
            From the \href{http://wiki.openwrt.org/doc/howto/http.mini-httpd}{tutorial for httpd}
53

    
54
        \textbf{How to remove library showing up in make menuconfig?}
55

    
56
            You only need to remove the package directory from the /package directory. Then when make menuconfig is executed, it will scan through the /package directory to find if there is any new/removed packages
57

    
58

    
59
        \textbf{ERROR: SyntaxError: encoding problem: utf8}
60

    
61
            Add dependency \texttt{python-codecs}
62
            Below is the error in more detail
63

    
64
            \begin{lstlisting}
65
Traceback (most recent call last):
66
  File "<stdin>", line 1, in <module>
67
  File "/usr/lib/python2.7/networkx/__init__.py", line 84, in <module>
68
    import networkx.generators
69
  File "/usr/lib/python2.7/networkx/generators/__init__.py", line 5, in <module>
70
    from networkx.generators.classic import *
71
  File "/usr/lib/python2.7/networkx/generators/classic.py", line 21, in <module>
72
    from networkx.algorithms.bipartite.generators import complete_bipartite_graph
73
  File "/usr/lib/python2.7/networkx/algorithms/__init__.py", line 4, in <module>
74
    from networkx.algorithms.centrality import *
75
  File "/usr/lib/python2.7/networkx/algorithms/centrality/__init__.py", line 1, in <module>
76
    from .betweenness import *
77
  File "/usr/lib/python2.7/networkx/algorithms/centrality/betweenness.py", line 1
78
SyntaxError: encoding problem: utf8
79
            \end{lstlisting}
80

    
81
        \textbf{ERROR: ImportError: No module named lib2to3.pgen2.parse}
82
            Do we even need the function read\_gml()
83

    
84
            \begin{lstlisting}
85
Traceback (most recent call last):
86
  File "<stdin>", line 1, in <module>
87
  File "/usr/lib/python2.7/networkx/__init__.py", line 87, in <module>
88
    import networkx.readwrite
89
  File "/usr/lib/python2.7/networkx/readwrite/__init__.py", line 14, in <module>
90
    from networkx.readwrite.gml import *
91
  File "/usr/lib/python2.7/networkx/readwrite/gml.py", line 44, in <module>
92
    from lib2to3.pgen2.parse import ParseError
93
ImportError: No module named lib2to3.pgen2.parse
94
            \end{lstlisting}
95

    
96
    \subsection{Install only few files in networkx needed for the project}
97

    
98
        \begin{lstlisting}
99
>>> from networkx.algorithms.centrality import *
100
Traceback (most recent call last):
101
  File "<stdin>", line 1, in <module>
102
  File "/usr/lib/python2.7/networkx/__init__.py", line 87, in <module>
103
    import networkx.readwrite
104
  File "/usr/lib/python2.7/networkx/readwrite/__init__.py", line 14, in <module>
105
    from networkx.readwrite.gml import *
106
  File "/usr/lib/python2.7/networkx/readwrite/gml.py", line 44, in <module>
107
    from lib2to3.pgen2.parse import ParseError
108
ImportError: No module named lib2to3.pgen2.parse
109

    
110
>>> from networkx.algorithms.centrality import betweenness
111
Traceback (most recent call last):
112
  File "<stdin>", line 1, in <module>
113
  File "/usr/lib/python2.7/networkx/__init__.py", line 43, in <module>
114
    from networkx import release
115
ImportError: cannot import name release
116

    
117
        \end{lstlisting}
118

    
119
        The python2.7 package is dependent to the libssl package (openssl runtime librairies).
120

    
121
        Questions
122

    
123
        ? When is the Python2.7 folder got generated
124

    
125
        Much simpler solution. I can simply choose to include the logging module in [make menuconfig]
126

    
127
        \textbf{Oct 21, 2015} Leonardo said that we can just drop the attempt with networkx, it's not worth the effort.
128

    
129
    \subsection{Prepartion for Hello World program}
130
        \subsubsection{How templates work in C++}
131

    
132
            From the \href{https://www.sgi.com/tech/stl/stl_introduction.html}{Introduction to the Standard Template Library}
133

    
134
        \subsubsection{What is dynamic linking that Leonardo talked about?}
135

    
136
        \subsubsection{pointer for dummy}
137
            \lstinline{&} = address operator
138

    
139
            \lstinline{*} = reference operator. \lstinline{*(1000) = Value at address 1000}
140

    
141
            A pointer must know how big the house it is pointing to. So if paul is an int, only an int pointer can point to it. If paul is a float, then only a float pointer can point to it, and so on.
142

    
143

    
144
            \begin{lstlisting}
145

    
146
            \end{lstlisting}
147

    
148
            \lstinline{int *melissa} = creating a pointer melissa
149

    
150
            \lstinline{int* melissa} = another way to create a pointer melissa. In the "Thinking in C++", pointer is created using this form.
151

    
152
            \lstinline{int * melissa} = another way to create a pointer melissa.
153

    
154
            \lstinline{int **ramon} = pointer to a pointer
155

    
156
            A \textbf{string} in C is simply a pointer to a char that has the convention of being the start of a sequence of characters that ends in '\textbackslash0'.
157

    
158
            \href{http://www.c4learn.com/c-programming/c-pointer-to-array-of-string/}{c4learn} website is a useful tutorial.
159

    
160
            \begin{lstlisting}
161
char *path[] // an array of pointers
162
char *path // a single pointer
163
char *path = "ABCD" //
164
            \end{lstlisting}
165

    
166
            \textbf{Question related to pointer}
167

    
168
            \begin{lstlisting}
169
# int arr[] = {7, 11, 13};
170
arr =       0x7ffc71ca1f90
171
&(*arr)) =  0x7ffc71ca1f90
172
&arr =      0x7ffc71ca1f90
173
&arr = 140722217557904
174
??? why why why, plusing with 4, resulting in plusing with 16 ???
175
sizeof(int) = 4
176
arr + sizeof(int) = 140722217557920
177
arr + 2*sizeof(int) = 140722217557936
178
//
179
&arr + sizeof(int) = 140722217557952
180
arr + 4 = 140722217557920
181
arr + 8 = 140722217557936
182
&arr[1] = 0x7ffc71ca1f94
183
*(&arr[1]) = 11
184
arr[1] = 11
185

    
186
# char char_arr[] = {'x', 'u', 'a', 'n', '
187
char_arr = xuan
188
*char_arr = x
189
&char_arr = 0x7ffc71ca1fa0
190
&(*char_arr) = xuan
191
??? Why char_arr is printed out completely, why arr only print number 10???
192
            \end{lstlisting}
193

    
194

    
195
        \subsubsection{Passing a pointer vs Pass-by-reference (PBR)}
196
            \begin{lstlisting}
197
// Passing a poitner to a function
198
void f(int* p) {
199
    cout << p; // 0065FE00
200
    cout << *p; // 16
201
    *p = 5;
202
    cout << *p; // 5
203
}
204

    
205
int main() {
206
    int x = 16;
207
    f(&x)
208
}
209
            \end{lstlisting}
210

    
211
            Calling a function that take a reference is cleaner
212

    
213
            Assigning to \texttt{r} is the same as assigning to the variable that \texttt{r} \emph{references}
214

    
215
            \begin{lstlisting}
216
// Pass-by-reference
217
void f(int& r) {
218
    cout << r; // 16
219
    cout << &r; // 0065FE00
220
    r = 5;
221
    cout << p; // 5
222
}
223

    
224
int main() {
225
    int x = 16;
226
    f(x)
227
}
228
            \end{lstlisting}
229

    
230

    
231
    \subsection{Write a Hello World program for Boost Graph Library}
232

    
233
        Reading \href{http://www.boost.org/doc/libs/1_55_0/libs/graph/doc/quick_tour.html}{Graph Doc Quick Tour}
234

    
235
        \subsubsection{Notation}
236
            \textbf{STL} = Standard Template Library